Forums Register Login

print stream empty file

+Pie Number of slices to send: Send
import java.io.*;
class Characters {
public static void main(String [] args) throws IOException{
char vChar;
PrintWriter out= new PrintWriter(new BufferedWriter(new FileWriter("Characters.txt")));
for (int i=33;i<255;i++) {
vChar=(char) i;
System.out.println("");
String vString = Integer.toString(i);
out.write(vString);
}
}
this file produces output to consele and also creates file "Character.txt" but file is empty
i m unable to figure out why?
any comment.

+Pie Number of slices to send: Send
hi gul
u should try use out.print(vString),i had trouble with the
write() method.
+Pie Number of slices to send: Send
can body tell me what's wrong with this code and write method
thax
+Pie Number of slices to send: Send
add out.flush() after the write or close your writers in the reverse order you opened them.
bye
A feeble attempt to tell you about our stuff that makes us money
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1621 times.
Similar Threads
Help me fix this code, please.
Seaching and Replacing text program
mock: java.io.File
File Read & Writing
i/o about printwriter
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:33:18.