1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
harina [27]
3 years ago
11

Write a Java program which reads a text file and writes the content into a new file. During the read-write process, convert all

the upper case letters into lower case ones. In other words, your programming task is to create a new file with the same content of the original file, only that all the upper case letters are converted into lower case ones in the new file.
Computers and Technology
1 answer:
Veseljchak [2.6K]3 years ago
6 0

Answer:

Kindly go to the explanation part for the code you seek.

Explanation:

This is the Code to Copy:

package file;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.DataInputStream;

import java.io.FileInputStream;

import java.io.FileWriter;

import java.io.InputStreamReader;

import java.util.Scanner;

public class file

{

public static void main(String []args)

{

try

{

System.out.print("Type a file name: ");

//declare scanner for keyboard input

Scanner reader = new Scanner(System.in);

//scan the input file name

String infilename=reader.nextLine();

//define file stream

FileInputStream fstream = new FileInputStream(infilename);

DataInputStream in = new DataInputStream(fstream);

//define the buffer reader

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

String outfilename = "output.txt";

FileWriter fileWriter = new FileWriter(outfilename);

//declare buffer writer for file write

BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);

String strLine,filename;

int status = 0;

int i=0;

//read lines one by one from input file

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

{

String temp="";

//for each character in a line

for(int k=0;k<strLine.length();k++)

{

char c;

c=strLine.charAt(k);

//if the character is uppercase

if(Character.isUpperCase(c))

//make the character lowercase and append it to the output line

temp +=Character.toLowerCase(c);

else

//character is not lowercase. append to the output line without changing it

temp += c;

}

//write the line to the file

bufferedWriter.write(temp+"\n");

}

//close the input file

in.close();

//close the output file

bufferedWriter.close();

}

catch (Exception e)

{

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

}

}

}

You might be interested in
host b is sending an email intented for the user on host a to the mail server what protocol is being used to send the message
KatRina [158]

Answer:

SMTP

Explanation:

This is the SMTP or the Simple Mail Transfer Protocol. It is the push protocol and is used to send the mail message. Whereas POP3 and IMAP are meant for retrieving the message. These are the three main types of protocols associated with mail services. And the correct answer here is certainly the SMTP.

3 0
3 years ago
What do astronomers call a system that is composed of more than two stars?
Nezavi [6.7K]
Nazils system is the anwser
7 0
3 years ago
Read 2 more answers
________ enables advertisers to display more relevant ads based on user's search and browsing history. FIP NORA A Web bug An int
Arturiano [62]

Answer:

Behavioural targeting

Explanation:

Behavioural targeting is the method that enables advertisers to display more relevant ads based on user's search and browsing history. This is an online targeting technique that collects information from a particular user. This information comes from the person's browsing history. The information that comes from the browsing history enable advertisers to display specific targeted ads that would most appeal to the person in question.

7 0
3 years ago
10 computer and operating systems errors​
babunello [35]

Answer:

what is

Explanation:

3 0
2 years ago
Read 2 more answers
Denary is measured in Base 10 Binary is measured in Base________
anastassius [24]

Answer:

hey! the answer to your question is -

binary is measured in base 2

3 0
3 years ago
Other questions:
  • A customer states that when she removes the printed pages from her laser printer output tray, the black ink smears all over her
    10·1 answer
  • Driving while wearing headphones or earphones
    12·2 answers
  • Ethan wants to change the font in his document. He should _____.
    8·2 answers
  • Cuales son los accesorios electronicos mas recomendados?
    6·1 answer
  • Select the correct answer.
    8·1 answer
  • describe a real-world scenario where data is collected and needs to be both accurate and precise for the safety of the community
    9·1 answer
  • True or False <br><br> The term virus and malware may be used interchangeably.
    13·1 answer
  • From space, the world looks very different. Describe what these surfaces look like from an airplane’s view:
    13·2 answers
  • _____________are where you get down to business and enter data in a worksheet
    12·1 answer
  • windows switches to secure desktop mode when the uac prompt appears. what is the objective of secure desktop mode?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!