汉字编码问题! 你使用Properties.load就可以看到 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给你一段程序去转换,要不要:import java.io.*;/** * Created by IntelliJ IDEA. * User: Administrator * Date: 2004-7-14 * Time: 9:36:53 * To change this template use File | Settings | File Templates. */public class Ascii2Native { static int getHex(byte b){ int i=-1; if(b>=97 && b<=102){ i=b-87; }else if(b>=65 && b<=70){ i=b-55; }else if(b>=48 && b<=57){ i=b-48; } return i; } static char byte2ToChar(byte b1, byte b2, byte b3, byte b4) { return (char) (((((getHex(b1)<<4)+getHex(b2))<<4)+getHex(b3)<<4)+getHex(b4)); } public static void main(String[] args) throws FileNotFoundException, IOException { System.out.println("args.length = " + args.length); if (args.length != 4 || !"-encoding".equals(args[0])) { System.out.println("using \nAscii2Native -encoding XXX inputfile outputfile"); return; } File inFile = new File(args[2]); FileInputStream in = new FileInputStream(args[2]); FileOutputStream out = new FileOutputStream(args[3]); byte b[] = new byte[(int) inFile.length()]; StringBuffer buf = new StringBuffer(); in.read(b); for (int i = 0; i < b.length; i++) { if(b[i]=='\\' && b[i+1]=='u'){ buf.append(byte2ToChar(b[i+2],b[i+3],b[i+4],b[i+5])); i+=5; } else buf.append((char)b[i]); } out.write(buf.toString().getBytes()); out.close(); in.close(); }} native2ascii -reverse -encoding Cp1381 xxxx.properties oneone.txt native2ascii -reverse -encoding Cp1381 xxxx.properties oneone.txt 什么意思呀? native2ascii属于j2sdk(jvm)命令.自己去查吧。目前不知道哪一种编辑器支持这咱转换格式。用native2ascii命令可以恢复汉字。 native2ascii -reverse -encoding Cp1381 xxxx.properties oneone.txt可以,早知道我就不写那段代码了 请教一个关于SESSION的问题 怎样学好Java Web? 项目结尾,要做日志记录 写入数据库表 日历控件My97DatePicker的问题 求一个log4j配置文件 JSP自定义标签问题,急!!!!!! 用java程序获取js里数组的数据 一个困惑的问题(有代码) 麻烦大家帮我看看 3Q! 急需要这样的代码,谢谢! 帮忙一下 请问这种用静态方法返回一个数据库的连接,是否这种方法将降低数据库连接的效率呢。 连接池的使用问题
* Created by IntelliJ IDEA.
* User: Administrator
* Date: 2004-7-14
* Time: 9:36:53
* To change this template use File | Settings | File Templates.
*/
public class Ascii2Native {
static int getHex(byte b){
int i=-1;
if(b>=97 && b<=102){
i=b-87;
}else if(b>=65 && b<=70){
i=b-55;
}else if(b>=48 && b<=57){
i=b-48;
}
return i;
}
static char byte2ToChar(byte b1, byte b2, byte b3, byte b4) {
return (char) (((((getHex(b1)<<4)+getHex(b2))<<4)+getHex(b3)<<4)+getHex(b4));
} public static void main(String[] args) throws FileNotFoundException, IOException {
System.out.println("args.length = " + args.length);
if (args.length != 4 || !"-encoding".equals(args[0])) {
System.out.println("using \nAscii2Native -encoding XXX inputfile outputfile");
return;
}
File inFile = new File(args[2]);
FileInputStream in = new FileInputStream(args[2]);
FileOutputStream out = new FileOutputStream(args[3]);
byte b[] = new byte[(int) inFile.length()];
StringBuffer buf = new StringBuffer();
in.read(b);
for (int i = 0; i < b.length; i++) {
if(b[i]=='\\' && b[i+1]=='u'){
buf.append(byte2ToChar(b[i+2],b[i+3],b[i+4],b[i+5]));
i+=5;
}
else
buf.append((char)b[i]);
}
out.write(buf.toString().getBytes()); out.close();
in.close();
}}
什么意思呀?
目前不知道哪一种编辑器支持这咱转换格式。
用native2ascii命令可以恢复汉字。