Java IO 学习摘要
import java.io.*;public class TestReaderWriter {private static final String s = File.separator;public static void main(String[] args) {BufferedReader br = null;System.out.println("-------------------BufferedReader 读取文件D:\\1.java ---------------------------");try{br = new BufferedReader(new FileReader("d:"+s+"1.java"));}catch(FileNotFoundException e){System.out.println("in 文件未找到!");}String str = null;try{while(br.readLine()!=null){str = br.readLine();System.out.println(str);}br.close();}catch(IOException e){System.out.println("读取失败!");}BufferedWriter bw = null;System.out.println("-------------------BufferedWriter 写入文件D:\\test.java ---------------------");try{bw = new BufferedWriter(new FileWriter("d:"+s+"test.java"));}catch(IOException e){e.printStackTrace();}try{if(bw!=null){System.out.print("正在写入中");for(int i=0;i<100;i++){bw.write(i);try{Thread.sleep(500);}catch(InterruptedException e){System.out.println("线程休眠失败!");}System.out.print(".");}System.out.println("写入成功!");}bw.close();}catch(IOException e){System.out.println("写入失败!");}//System.out.println("Hello World!");}}?