----------------解决方案--------------------------------------------------------
import java.io.*;
public class testReaderWriter{
/*--------------------------------------
*<br>功能概述:测试字节流到字节符流的转换
---------------------------------------*/
public void testOperate(){
try{
log("创建文件字节输入流对象...");
log("创建字节流到字符流转换桥...");
log("创建字符流输入对象...");
FileInputStream fis = new FileInputStream("C:\\aaa\\test.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
log("创建文件字符输出流对象...");
FileWriter fw = new FileWriter("D:\\bbb\\test.txt");
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
String strText = "";
String strTemp = "";
//采用字符的处理方式,将文件内容拷贝到指定字符串
while((strTemp=br.readLine())!=null){
strText += strTemp;
}
log("文件数据内容是:");
log(strText);
log("将数据内容拷贝到指定文件中");
pw.write(strText);
pw.flush();
log("关闭各种数据流");
fis.close();
isr.close();
br.close();
fw.close();
bw.close();
pw.close();
}
catch(IOException e){}
}//testOperate()
public void log(String strInfo){
System.out.println(strInfo);
}//log()
public static void main(String args[]){
testReaderWriter trw = new testReaderWriter();
trw.testOperate();
}//main()
}/**testReaderWriter*/
书上给的 正好会
----------------解决方案--------------------------------------------------------