【Java学习笔记】文本文件的复制(流的读写)
作者:gnuhpc
出处:http://www.cnblogs.com/gnuhpc/
import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class CopyText { public static void main(String arg[]) { if(arg.length != 2) { System.out.println("Usage: java CopyText <infile> <outfile>"); return; } try { int value; FileReader in = new FileReader(arg[0]); FileWriter out = new FileWriter(arg[1]); while((value = in.read()) != -1) out.write(value); in.close(); out.close(); } catch(IOException e) { System.out.println(e); } } }