代码:新手学IO
[code="java"]
package woca;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class FilterOutputTester {
public static void main(String[] args) throws IOException {
FileOutputStream out1 = new FileOutputStream("D:\test.txt");
BufferedOutputStream out2 = new BufferedOutputStream(out1, 256);
DataOutputStream out = new DataOutputStream(out2);
out.writeUTF("你好啊");
out.writeUTF("再见");
out.close();
InputStream in1 = new FileInputStream("D:\\test.txt");
BufferedInputStream in2 = new BufferedInputStream(in1, 3);
DataInputStream in = new DataInputStream(in2);
System.out.println(in.readUTF());
in1.close();
}
}
[/code]
大家也能看到我往 D盘test里边先写入 了 字符"你好啊"又写入了"再见" 也写入进去了 但是读取出来的却只有[color=red]你好啊[/color]这是怎么回事啊?
谢谢了 ! 我实在是想不到答案了!