编码问题,请教相关高手!!
工作环境:
OS:windows2000
JRE:SUN jdk1.42
另,JBuider X
工作任务:
程序从一个Excel文件中读出数据,写入另一个文本文件
应用程序:
读Excel,用java Excel API
写入.csv,用:
File fileCSV = null;
FileWriter fwCSV = null;
FileReader fileReader = null;
BufferedReader bufferdReader = null;
PrintWriter out = null;
.....
问题描述:
如果写入文本文件的内容不作编码转换,汉字等就会为?号,数字没变[假若用jre:1.42打成的exe程序的话,如果是在jbx中运行则是好的]
如果转换:
try{
fileRW.writeFile(new String[] {new String(arrALineExcel[0].getBytes("Unicode"),"GB2312"),
new String(arrALineExcel[1].getBytes("Unicode"),"UTF-8"), new String(arrALineExcel[2].getBytes("ISO8859_1"),"Unicode"),
new String(arrALineExcel[3].getBytes("GB2312"),"ISO8859_1"), new String(arrALineExcel[4].getBytes("GBK"),"Unicode"),
new String(arrALineExcel[5].getBytes("Unicode"),"ISO8859_1"), new String(strErr.getBytes("GBK"),"Unicode")});
}catch(Exception e){}
.....
其中转为Unicode的,全没有了;转为其它的,则不是汉字了
请兄弟们指教!!