Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Read/Write to Files using BufferedReader, FileReader, FileWriter, and PrintWriter: Thank you! You will be reading from and writing to files. You should prompt the

Java Read/Write to Files using BufferedReader, FileReader, FileWriter, and PrintWriter: Thank you!

You will be reading from and writing to files. You should prompt the user for a manifest file name, which should contain the name of additional files, one per line. Then, you should read the contents of each of these files and write them to a single new file. The name of the new file should be the name of the manifest with the additional extension .out. If there is a problem reading or writing to a file, you should print an appropriate error message. If you try to read a file from your project, it will look for it in the application root. This is inside the same folder as src. Place new files there (Right-Click on project in workspace, then File > New File to create an empty, extension-less file).

Input files

manifest.txt

file1.txt Hello file2.txt World file3.txt How are you?

Output

Enter manifest filename: manifest.txt

manifest.txt.out Hello World How are you?

package lab10;

import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; Code Template:

public class C10 {

public static void main(String[] args) { System.out.println("input manifest file name"); Scanner in = new Scanner(System.in); String name = in.nextLine(); // TODO // create a reader and writer object // use the reader to read the names of input files from the manifest file and // for each file name, use the same reader to read the content of the file, and write to the output file. // don't forget to flush the writer in the end in.close(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Solve the equation. |x - 2| =

Answered: 1 week ago

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago