Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone please explain to me why something that looks so simple, I have seen others provide the answer and code on chegg. But I

image text in transcribed

image text in transcribed

Can anyone please explain to me why something that looks so simple, I have seen others provide the answer and code on chegg. But I am confused what this program is to do? Do I make a file? I made a file that I named lab10 in notepad. I have tried everything and I am so confused what my teacher wants. I feel that my program is not outputting what my teacher wants. It doesn't seem to be reading anything or outputting to a file. Please comment back to my questions after you answer with code and break down what my teacher means. Please help me get the right output I am feeling so defeated right now.

8 SE- writeFile.java Fileretrieval.java package-info.java Filestring.java X 2 package writingfiles; ze import java.io.BufferedReader; 4 import java.io.BufferedWriter; 5 import java.io.FileReader; 6 import java.io.FileWriter; 7 import java.io.IOException; 8 public class Filestring { 9 public static void main(String[] args) throws IOException 10 { String datal="ABC", data="DEF", data3="GHI", data4="JKL", data5="MNO"; 12 FileWriter writer=new FileWriter("lab10.txt"); 13 BufferedWriter buffWriter=new BufferedWriter(writer); buffWriter.write(datal+" "); 15 buffWriter.write(data2+" "); 16 buffwriter.write(data3+" "); 17 buffwriter.write(data4+" "); $18 buffwriter.write(data5+" "); 19 buffWriter.close(); FileReader reader=new FileReader("lable. txt"); BufferedReader buffReader=new BufferedReader(reader); 22 String datab=buffReader.readLine(); a 14 vaSE- 20 21 ava e Console X Filestring (Java Application] C:\Users\Sally\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64. 14.0.2.2 File contents are: ABC DEF GHI UKL MANO JavaSE ava fojava ery Lase Writable nSER 20:44 705 f search Task 3. IOStreams (5 points) Write a Java program that writes fives strings to the file lab10.txt, and then reads those five strings back into different variables. The newer versions of Java have changed how they work with file output streams! FileOutputStream throws an exception of type FileNotFoundException, and DataOutputStream.close() throws an IOException In practice, you won't run into these in the lab. But you do need to call them out when declaring static void main: public static void main(String[] args) throws IOException handles both cases. Rubric: Student name and today's date is a comment in the first line of the programs: -5 points if fails Screenshot and program code: -5 points if fails Program works: 5 points Please paste a screenshot of a successful program run, and copy-and-paste the source code from your main program's java file, here

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions