日期:2014-05-20  浏览次数:20801 次

IO流的问题 请大家帮忙解决
E:\\Eclipse wokspace\\dujianfeng12\\src\\zuoye2\\ZhuCaiDan.java这个目录下的文件的数据总是写不到E:\\Eclipse wokspace\\dujianfeng12\\src\\zuoye2\\test.java这个目录下的文件中





package javaseio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;

public class Test06 {
public static void main(String[] args) throws IOException {
int c;
InputStreamReader isr = new InputStreamReader(new FileInputStream("E:\\Eclipse wokspace\\dujianfeng12\\src\\zuoye2\\ZhuCaiDan.java"));
OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("E:\\Eclipse wokspace\\dujianfeng12\\src\\zuoye2\\test.java"));
while((c=isr.read())!=-1){
System.out.print((char)c);
osw.write((char)c);
}
System.out.println("完成");
}

}

------解决方案--------------------
Java code

osw.flush();
osw.close();