求,字符串压缩变短的算法。
解决方案 »
- struts1和struts2的问题
- 请教大家关于权限控制的问题
- Spring AOP 的一个问题
- JFreechart 生成png图片后,怎样直接输出到页面
- Struts+hibernate Servlet action is not available 在线等
- 熟悉 jacob 的朋友请进来看看!
- 急求:2000server ntfs web应用无法访问文件系统
- struts问题:如何实现修改功能?
- 关于在ibatis或者mybatis中使用读写两个连接池的做法
- ERROR org.apache.struts2.dispatcher.Dispatcher - Dispatcher initialization faile
- hibernate的SQL语句
- 请求下面这个关于struts验证产生的错误的帮助
try {
// Encode a String into bytes
String inputString = "LLLLLLLLLLLLLLLLLLLLLLLLLOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG??";
byte[] input = inputString.getBytes("UTF-8"); // Compress the bytes
byte[] output = new byte[100];
Deflater compresser = new Deflater();
compresser.setInput(input);
compresser.finish();
int compressedDataLength = compresser.deflate(output);
System.out.println("Input string:" + inputString);
System.out.println("Input length:" + input.length);
System.out.println("Compressed length:" + compressedDataLength);
System.out.println("Compressed string:" + new String(output)); // Decompress the bytes
Inflater decompresser = new Inflater();
decompresser.setInput(output, 0, compressedDataLength);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result);
decompresser.end(); // Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
System.out.println("Decompressed string:" + outputString);
} catch(java.io.UnsupportedEncodingException ex) {
// handle
} catch (java.util.zip.DataFormatException ex) {
// handle
}
}
参考这个 http://www.java2000.net/viewthread.jsp?tid=4989
http://list.mall.taobao.com/1307/g-s-----40-0--1307.htm
在这个页面中搜索 中国 两个字 这个页面url就会变成
http://list.mall.taobao.com/1307/g-s----g,23ilt6q-40-0--1307.htm实际上 这个 23ilt6q 就是中国两个字 压缩后变成的字符串。
这是压缩么???
只是编码而已! 比如base64....
你看看这个