i have already send u this import java.io.*; class a{ static public void main(String[] args)throws Exception{ CharArrayWriter caw=new CharArrayWriter(); caw.write(65); caw.close(); caw.writeTo(new FileOutputStream"c:\\yasir.txt")); }} this is not writting in file tell me what i do.
Steve Deadsea
Ranch Hand
Joined: Dec 03, 2001
Posts: 125
posted
0
There are several problems with your code: 1) It has a syntax error, it is missing an open paren before the file name. 2) It doesn't compile because CharArrayWriter.writeTo() takes a Writer not an OutputStream. 3) You don't flush and close the File, which causes the character not to be written to the file. Here is some code that works:
Out of curiosity, why are you using the CharArrayWriter? You could write to the FileWriter directly without the intermediate buffer.