Exercise
Convert A Text File To Uppercase
Objetive
Write a program to read a text file and dump its content to another file, changing the lowercase letters to uppercase.
You must deliver only the ".cs" file, with you name in a comment.
Example Code
package FileLowerCaseToUpperCase;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
System.out.print("Enter name file: ");
String fileName = new Scanner(System.in).nextLine();
if ((new java.io.File(fileName)).isFile())
{
java.io.FileReader fileRw = new java.io.FileReader(fileName);
java.io.BufferedReader fileRwBufferedReader = new java.io.BufferedReader(fileRw);
java.io.FileWriter fileWr = new java.io.FileWriter(fileName + ".dat");
String line;
do
{
line = fileRwBufferedReader.readLine();
if (line != null)
{
fileWr.write(line.toUpperCase() + System.lineSeparator());
}
} while (line != null);
fileRw.close();
fileWr.close();
}
}
}