Uppercase file converter?
843789Oct 5 2009 — edited Oct 5 2009I tried, but it seemed that there is a problem with the following codes. Can you please help me to write the correct one to create the uppercase file converter?
Thank you!!
import java.util.Scanner; // Needed for the Scanner class
import java.io.*; // Needed for file classes
public class Uppercase2
{
public static void main(String[] args) throws IOException
{
String filename;
String filename2;
String writing;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the first filename.
System.out.print("Enter the first filename: ");
filename = keyboard.nextLine();
// get the second filname
System.out.print("Enter the second filename: ");
filename2 = keyboard.nextLine();
// Open the reading file.
FileReader freader = new FileReader(filename);
BufferedReader inputFile = new BufferedReader(freader);
// open output file
FileWriter fwriter = new FileWriter(filename2);
PrintWriter outputFile = new PrintWriter(fwriter);
//writing = inputFile.readLine();
while ((writing = inputFile.readLine()) != null)
{
System.out.println(writing);
// writing = inputFile.readLine();
String upper = writing.toUpperCase();
System.out.println(upper);
outputFile.println(upper);
}
// close IO streams
outputFile.close();
inputFile.close();
}
}