package brad; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.InputStreamReader; import java.io.PrintWriter; public class NewCopier { public static void main(String[] args) throws Exception { PrintWriter pen; // Prints to user pen = new PrintWriter(System.out, true); PrintWriter copypen; // Prints to file BufferedReader eyes; // Reads from user InputStreamReader istream; istream = new InputStreamReader(System.in); eyes = new BufferedReader(istream); BufferedReader copyeyes; // Reads from file // Prompt the user and get two file names pen.print("Enter the name of the file to copy from: "); pen.flush(); String copyfrom; copyfrom = eyes.readLine(); pen.print("Enter the name of the file to copy to: "); pen.flush(); String copyto; copyto = eyes.readLine(); pen.println("I will now copy two lines from " + copyfrom + " to " + copyto); // Create the things to read from and write to the two files. File fromfile; fromfile = new File(copyfrom); File tofile; tofile = new File(copyto); copypen = new PrintWriter(tofile); FileReader fromfilereader; fromfilereader = new FileReader(fromfile); copyeyes = new BufferedReader(fromfilereader); // Read two lines from the first file and write to the second file. String line; line = copyeyes.readLine(); copypen.println(line); line = copyeyes.readLine(); copypen.println(line); pen.println("FINISHED!"); copypen.close(); copyeyes.close(); } // main(String[]) } // class NewCopier