我向文本文件写入了数据,但文件中的数据不正确。我认为这是OutpubStream的问题,因为我在前面的步骤中显示数据,并且它们是正确的。来自OutputStream(Java)的文件中的数据输入不正确
private void Output(File file2) {
// TODO Auto-generated method stub
OutputStream os;
try {
os = new FileOutputStream(file2); //file2-it is my output file, all normal with him
Iterator<Integer> e=mass.iterator();
int r=0;
while(e.hasNext()){
r=e.next();
System.out.println(r);//display data-all be correct
os.write(r);//I think problem create in this step/
}
os.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
输入数据FILE1.TXT FILE2.TXT
3 strahge tokens plus !-68DU
感谢答案
10
56
2
33
45
21
15
68
54
85
输出数据,原谅我的英语。
我看了你的问题,大约3次,我仍然不知道什么是所需的输出 – 2013-04-30 16:30:39
难道是一个字节顺序标记? – Fildor 2013-04-30 16:40:03