Write a program which reads a file and creates a file with the same contents of
ID: 3689885 • Letter: W
Question
Write a program which reads a file and creates a file with the same contents of all lower case letters. Keep in mind that other characters are not affected.
Create your own file to test your program. Your job is to set up the input and output files to have the program read from a file and write to a file. Here is a basic program that will accomplish what is desired:
import java.io.*;
class InputOutput
{
public static void main(String args[])throws Exception
{
FileReader fr = new FileReader("Exercise03.in");
FileWriter fw = new FileWriter("Exercise03.out");
Answer6
int ch;
ch = fr.read();
while(ch != -1)
{
if((char)ch>='A' && (char)ch<='Z')ch = ch +('a'-'A');
fw.write((char)ch);
ch = fr.read();
}
fr.close();
fw.close();
}
}
Explanation / Answer
Exercise03.in:
Big night of basketball - @Warriors chasing 73 and a farewell for an
all-timer, @KobeBryant. NBA fans feeling like:
Exercise03.out:
big night of basketball - @warriors chasing 73 and a farewell for an
all-timer, @kobebryant. nba fans feeling like:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.