我用DataOutputStream流来写一个data.txt的文件时 File aFile=new File("c:\\data.txt"); String s=new String("Garbage in, garbagae out"); DataOutputStream myStream=new DataOutputStream( new FileOutputStream(aFile)); myStream.writeChars(s);编译写入之后,打开data,txt之中的文本却是G a r b a g e i n , g a r b a g e o u t 为什么会多了这么多的空格?
File aFile=new File("c:\\data.txt");
String s=new String("Garbage in, garbagae out");
DataOutputStream myStream=new DataOutputStream(
new FileOutputStream(aFile));
myStream.writeChars(s);编译写入之后,打开data,txt之中的文本却是G a r b a g e i n , g a r b a g e o u t
为什么会多了这么多的空格?
就没问题了
你用writeChars当然出现空格了
用s.getBytes();与原先s有什么不同?