Hi guys , I dont have idea on how to solve this problem . I attach my question but I dont know whether it is true or not.
Can you please help me

Given an output file named "data.txt" write the code fragment to

i ) set up the file and output stream 

ii) write the value of 101 to the stream 

iii) close the stream 

Tqvm

My Answer :

i) import java.io.*;

   File outFile = new File ("data.txt");
   FileOutputStream outFileStream  = new FileOutputStream(outFile);
   PrintWriter      outStream      = new PrintWriter(outFileStream);

 ii) outStream.println(“101”);

 iii) outStream.close();

Recommended Answers

All 4 Replies

so .. have you tested it?

what's supposed to be true? I can't look into the brain of your teacher, but I assume if he hands you an assignment it's a true assignment...

sorry i mean it's my answer correct ? can I test it ? I thought it can not be compile by eclipse

if it can't be compiled, it isn't correct.
obviously, what you've written above is not the entire code you should write to run it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.