📄 testendecode.java
字号:
package common.endecode.impl;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.language.Metaphone;
import org.apache.commons.codec.language.RefinedSoundex;
import org.apache.commons.codec.language.Soundex;
/**
*
* <p>Title: TestEnDecode.java</p>
* <p>Description: </p>
* <p>Copyright:OnewaveInc Copyright (c) 2007</p>
* <p>Company: OnewaveInc</p>
* @author Zhengrw
* @version 3.0
*/
public class TestEnDecode {
public void testBase64() {
// Base64 base64 = new Base64();
String str = "中文是ddd的一些条件";
byte[] enbytes = null;
String encodeStr = null;
byte[] debytes = null;
String decodeStr = null;
// enbytes = base64.encode(str.getBytes());
enbytes = Base64.encodeBase64(str.getBytes());
encodeStr = new String(enbytes);
// debytes = base64.decode(enbytes);
debytes = Base64.decodeBase64(enbytes);
decodeStr = new String(debytes);
System.out.println("编码前:" + str);
System.out.println("编码后:" + encodeStr);
System.out.println("解码后:" + decodeStr);
}
public void testHex() throws DecoderException {
Hex hex = new Hex();
String str = "中文";
char[] enbytes = null;
String encodeStr = null;
byte[] debytes = null;
String decodeStr = null;
enbytes = hex.encodeHex(str.getBytes());
encodeStr = new String(enbytes);
debytes = hex.decodeHex(enbytes);
decodeStr = new String(debytes);
System.out.println("编码前:" + str);
System.out.println("编码后:" + encodeStr);
System.out.println("解码后:" + decodeStr);
}
public void testMetaphone() {
Metaphone metaphone = new Metaphone();
RefinedSoundex refinedSoundex = new RefinedSoundex();
Soundex soundex = new Soundex();
for (int i = 0; i < 2; i++) {
String str = (i == 0) ? "resume" : "resin";
String mString = null;
String rString = null;
String sString = null;
try {
mString = metaphone.encode(str);
rString = refinedSoundex.encode(str);
sString = soundex.encode(str);
} catch (Exception ex) {
;
}
System.out.println("Original:" + str);
System.out.println("Metaphone:" + mString);
System.out.println("RefinedSoundex:" + rString);
System.out.println("Soundex:" + sString + "\n");
}
}
/**
* @param args
*/
public static void main(String[] args) {
TestEnDecode decoder = new TestEnDecode();
decoder.testBase64();
try {
decoder.testHex();
} catch (DecoderException e) {
e.printStackTrace();
}
// decoder.testMetaphone();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -