import java.io.*;
public class Test {
public static void main(String args[]){
try {
FileReader f=new FileReader( "E:\test.txt ");
BufferedReader in=new BufferedReader(f);
String s=null;
int i=0;
while ((s=in.readLine())!=null){
FileOutputStream out1 = new FileOutputStream( "E:\copytest.txt ");
BufferedOutputStream out2 = new BufferedOutputStream(out1,1);
DataOutputStream out = new DataOutputStream(out2);
out.writeUTF(s);
System.out.print(i+1+ " ");
System.out.println(s);
i++;
}
}catch(Exception e){
e.printStackTrace();
}
}
}
E:\copytest.txt 写入到这里的字符串是乱码?
另外要关那个流?