日期:2014-05-20 浏览次数:20918 次
import java.io.*; public class Faq { public static void main(String[] args) { BufferedReader br=null; BufferedWriter bw=null; try { br=new BufferedReader (new FileReader("f:\\java\\hao.txt")); bw=new BufferedWriter(new FileWriter("f:\\java\\iver99.txt")); String s=null; while((s=br.readLine()) !=null) { System.out.print(s); bw.write(s); //这里 s是个字符串 } System.out.println(); } catch(FileNotFoundException e) { System.out.println("file not found"); e.printStackTrace(); } catch(IOException e) { System.out.println("file error1"); e.printStackTrace(); } finally { try { br.close(); bw.close(); } catch(IOException e) { System.out.println("file error2"); e.printStackTrace(); } } } }