同样的程序 ,从 表里 取值,linux下生成文本文件
09 090 20 20 香熏保健丝贡被 20000 1
09 090 20 20 户外登山旅游帐篷 20000 0
09 090 20 20 户外登山休闲背包 6000 0
10 090 20 08 9410653
10 090 20 09 7179366
10 090 20 1 7866756
10 090 20 11 6546071
10 090 20 12 6556556
windows下生成的文件
09 090 20 20 香熏保健丝贡被 20000 1
09 090 20 20 户外登山旅游帐篷 20000 0
09 090 20 20 户外登山休闲背包 6000 0
10 090 20 08 9410653
10 090 20 09 7179366
10 090 20 10 7866756
10 090 20 11 6546071
10 090 20 12 6556556
不明白 ,为什么在linux上执行 并本地生成的文件 丢字符 ,反复试验了几个文件,好像文件中 有中文就会出现类似的莫名其妙丢字符现象 ,不可思议,用
file.createNewFile();
FileWriter resultFile = new FileWriter(file);
PrintWriter myFile = new PrintWriter(resultFile);
myFile.print(txt);
生成的
09 090 20 20 香熏保健丝贡被 20000 1
09 090 20 20 户外登山旅游帐篷 20000 0
09 090 20 20 户外登山休闲背包 6000 0
10 090 20 08 9410653
10 090 20 09 7179366
10 090 20 1 7866756
10 090 20 11 6546071
10 090 20 12 6556556
windows下生成的文件
09 090 20 20 香熏保健丝贡被 20000 1
09 090 20 20 户外登山旅游帐篷 20000 0
09 090 20 20 户外登山休闲背包 6000 0
10 090 20 08 9410653
10 090 20 09 7179366
10 090 20 10 7866756
10 090 20 11 6546071
10 090 20 12 6556556
不明白 ,为什么在linux上执行 并本地生成的文件 丢字符 ,反复试验了几个文件,好像文件中 有中文就会出现类似的莫名其妙丢字符现象 ,不可思议,用
file.createNewFile();
FileWriter resultFile = new FileWriter(file);
PrintWriter myFile = new PrintWriter(resultFile);
myFile.print(txt);
生成的
根据你的描述,我猜测是你没有设定好编码。--纯属猜测,仅供参考。
Writer resultFile = new OutputStreamWriter(new FileOutputStream(file), "gb18030");
PrintWriter myFile = new PrintWriter(resultFile);
myFile.print(txt);搂主最好使用 OutputStreamWriter 明确指定编码,以免不同的 LANG 环境变量产生影响。关于编码:
http://www.regexlab.com/zh/encoding.htm
090902020香熏保健丝贡被200001
090902020户外登山旅游帐篷200000
090902020户外登山休闲背包60000
1009020089410653
1009020097179366
100902017866756
1009020116546071
1009020126556556
windows下生成的文件
090902020香熏保健丝贡被200001
090902020户外登山旅游帐篷200000
090902020户外登山休闲背包60000
1009020089410653
1009020097179366
1009020107866756
1009020116546071
1009020126556556怪我眼拙,我怎么看不出来这两个有什么区别???????
10,090,20,10,7866756
本来字段用 tab相隔,粘贴到这里自动没了
我也怀疑是编码问题,只不过这方面所知有限,想不明白