import java.util.*; import java.io.*; public class FileIOTest { /* Copy an input file to an output file, channging all lertters to uppercase * The same approach can be used for character-at-a-time processing in the Colorize program. */ public static void main(String[] args) { String inputFileName = "sampleFile.txt"; // You will need to get this based on command-line argument. String outputFileName = "upperCasedFile.txt"; try { Scanner sc = new Scanner(new File(inputFileName)); PrintWriter out = new PrintWriter(new FileWriter(outputFileName)); while (sc.hasNextLine()){ // process one line String line = sc.nextLine(); line = line.toUpperCase(); for (int i= 0; i< line.length(); i++) // normally we might process each character in the line. out.print(line.charAt(i)); out.println(); } out.close(); } catch (IOException e) { e.printStackTrace(); } } }