Forums Register Login

Why no output is given here

+Pie Number of slices to send: Send
import java.io.*;

class File6{
public static void main(String[] s){
try{
File file = new File("f.txt");
FileWriter fw = new FileWriter(file);

fw.write("who is next\nI don't know\nok no problem");

FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);

String data;
while((data=br.readLine()) !=null)
System.out.println(data);

br.close();

}catch(IOException io){io.printStackTrace();}

}
}


This code is not showing any output .
I can't make out the problem , please help
Thanks in advnce
+Pie Number of slices to send: Send
fw.flush() after fw.write()!
+Pie Number of slices to send: Send
Thanks for the help
I have made a bad mistake
Rototillers convert rich soil into dirt. Please note that this tiny ad is not a rototiller:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1009 times.
Similar Threads
FileIO
Remove Line from Text File
FILE I/O
readLine() and read() functionality
reverse the text file and write
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:01:48.