| Author |
Problem : Writting Data Into File Using Channel
|
kayanaat sidiqui
Ranch Hand
Joined: Sep 04, 2008
Posts: 122
|
|
Hi,
I am using the following code for writting data in to file --
but the output file is as follows--
t e s t []
that is output file is having space in between each letter and unable to identify the new line character.
Could you please tell me where m i doing wrong?
Is there any other way to write and/or append data to a file?
Thanks,
Kaya.
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
http://faq.javaranch.com/java/UseCodeTags, don't quote text. I've changed it for you, see how much better that looks.
I've tried your code, and the characters are written using the big-endian Unicode charset (UTF-16BE). That's because ByteBuffer.putChar always uses two bytes for a character.
You should try using a different Charset, and then encode the string instead:
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Ravikanth Boorugadda
Greenhorn
Joined: Apr 07, 2009
Posts: 3
|
|
|
The file is getting written with Unicode characters. Use any editor which supports unicode to read the file. I tried with textpad, it is working fine.
|
 |
kayanaat sidiqui
Ranch Hand
Joined: Sep 04, 2008
Posts: 122
|
|
Thanks a lot Rob for your precious comments and solution. It helps a lot.
Also Thanks to Ravikanth.
|
 |
 |
|
|
subject: Problem : Writting Data Into File Using Channel
|
|
|