Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello. I would like to solve it in detail today with output Please and thank you Create a java application called FileIOExample. The application should

Hello. I would like to solve it in detail today with output Please and thank you

Create a java application called FileIOExample. The application should read contents from the first file and extract only numbers from it and write those numbers to the second file. Then the application should then read all numbers from the second file and display only the prime numbers to the terminal.

There are two files used in this program, the first file file1.txt containing text and digits, and another file file2.txt to write only the extracted numbers from the first file.

image text in transcribed

image text in transcribed

image text in transcribed

file1.txt X Source History QFOTBD BIG 1 This statistic shows the number of higher education 2 institutions in the United States from 1980 to 2017. 3 As can be seen in the graph, there were a total of 4 3803 higher education institutions across the 5 United States as of 2015. In 2016, there were 331 6 higher education institutions in California, the 7 highest number of any U.S. state. New York had the 8 second most higher education institutions with 967, 9 followed by Texas and Pennsylvania. file2.txt x Source History TB B20 1980 2 3 2017 1 2 3 4 5 6 3803 5 2015 2016 331 7 8 967 9 9 10 Output x DD Debugger Console x cpcs203_lab3 (run) * run: Picked up _JAVA_OPTIONS: -Xmx1024m 2017 3803 331 967 BUILD SUCCESSFUL (total time: 2 seconds) | When finished, make sure that the data written to the new file has been flushed from its buffer and that any system resources used during for running your code have been released. Note Check the input file existence before start reading from the input files, if the file does not exist, display a message then exit the program execution. Hints: The File and PrintWritter classes: exist in (java.io. *) package. You need to open input/output files for reading and writing using: File inputFile = new File("file1.txt"); File outputFile = new File("file2.txt"); File inputFilel = new File("file2.txt"); Make Scanner variable to read from input file and make Printwriter variable to write to output file using: Scanner input = new Scanner (inputFile); PrintWriter output = new PrintWriter (outputFile); Scanner input1 = new Scanner (inputFilel); Use close() method after completing the process of reading and writing operations on the file

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_2

Step: 3

blur-text-image_3

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

EXPLAIN the key functions of an HRIS and its key stakeholders.

Answered: 1 week ago

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. How will you, as city manager, handle these requests?

Answered: 1 week ago