CopyFileDemo.java package file_Stream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;public class CopyFileDemo {private static String str;public static void main(String[] args)
package file_Stream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class CopyFileDemo { private static String str; public static void main(String[] args) throws Exception { in(); out(); } public static void in() throws IOException { File f = new File("file/BoyNextDoor.txt"); FileInputStream in = new FileInputStream(f); byte[] buffer = new byte[1024]; int len = -1; while ((len = in.read(buffer)) != -1) { str = new String(buffer, 0, len); System.out.println(str); } in.close(); } public static void out() throws Exception { File ff = new File("file/zxf.txt"); FileOutputStream out = new FileOutputStream(ff, true); out.write(str.getBytes()); out.close(); } }