Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Final Prep Code 2014 CSIS-1410 Exercise File: 1. Use a BufferedReader to read th

ID: 666374 • Letter: F

Question

Final Prep Code 2014                                                                      CSIS-1410

Exercise File:
1. Use a BufferedReader to read the text from file Quote.txt,2. convert the text to all upper case letters3. write the converted text to a new file called QuoteUpperCase.txtWhite space should remain the same as in the original fileHint:   You can declare multiple resources in a try-with-resource statement. Just separate them with a semi-colon

Output:
Creating a new file QuoteUpperCase:

done

Explanation / Answer

import java.io.*;

public class TextFile {
    public static void main (String[] args) throws IOException {
                File file1 = new File("Quote.txt");
                File file2 = new File("QuoteUpperCase.txt");
                char CharCounter = 0;     
                BufferedReader in = (new BufferedReader(newFileReader(file1)));
                PrintWriter out = (new PrintWriter(new FileWriter(file2)));

                int ch;
                while ((ch = in.read()) != -1){

                    if (Character.isLowerCase(Ch)){
                        ch=Character.toUpperCase(Ch);
                         }
                        out.write(ch);
               
                          }
                in.close();
                out.close();
System.out.println("Creating a new file QuoteUpperCase: Done ");

    }     
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote