Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Uppercase file converter?

843789Oct 5 2009 — edited Oct 5 2009
I 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();
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2009
Added on Oct 5 2009
5 comments
4,856 views