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

Ok, so I had problems with this before in C++. Now I\'m dealing with it in Java,

ID: 3550660 • Letter: O

Question

Ok, so I had problems with this before in C++.  Now I'm dealing with it in Java, and need a touch of help.  Here's what I have to do:


Write a program that

? Asks the user for the names of two files

? Opens the first file for reading

? Opens the second file for writing

? Reads the contents of the first file, changes all characters to uppercase, and stores the results in the second file

The second file will be a copy of the first file, except that all the characters will have changed case.  


The two files can be found HERE:


http://www.filedropper.com/yippee

http://www.filedropper.com/skippie


Here's what I have so far.....


import java.util.Scanner;              // allows for Scanner class

import java.io.*;                     // allows for File I/O



public class ErnestTeeUpperFile {


    public static void main(String[] args) {

      

        Scanner keyboard = new Scanner (System.in);   //create scanner object for keyboard input

        

       System.out.print("Enter the name of the file to be READ: ");    //gets file name and stores it

       String readFile = keyboard.nextLine();

        

        System.out.print("Enter the name of the file to be WRITTEN: ");   //gets file name and stores it

        String writeFile = keyboard.nextLine();

        

        PrintWriter outputFile = new PrintWriter(readFile);



....here's where my brain slams on the brakes.  Any help is appreciated!

Explanation / Answer

//I have put lots off efforts for your problem .


import java.io.*;


import java.util.*;


class FileRead


{


public static void main(String args[])


{


try{


FileInputStream fstream = new FileInputStream("firstfile.txt");


DataInputStream in = new DataInputStream(fstream);


BufferedReader br = new BufferedReader(new InputStreamReader(in));


String strLine;


while ((strLine = br.readLine()) != null)


{

String new_words="";

Set<String> words = new HashSet<String>(Arrays.asList(strLine.split(" ")));


new_words=words.toUpperStirng();


try {


FileWriter fileWriter =new FileWriter(secondfile.txt);



BufferedWriter bufferedWriter =new BufferedWriter(fileWriter);


bufferedWriter.write(new_words);

bufferedWriter.close();


}


catch(IOException ex)


{


System.out.println("Error writing to file '"+ fileName + "'");


}

in.close();


}catch (Exception e){


System.err.println("Error: " + e.getMessage());


}

}

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