First of all writeUTF appends a 16 bit length, and then your actual
data.
When you read data back in, readUTF can get how long the string to
read
is, and then read exactly that much in.
If you need to write multiple items and read them back that way,
you can use writeUTF, but you should be carefull not to exceed 64k
strings.

More about writeUTF on java.sun:
http://java.sun.com/javase/6/docs/api/java/io/DataOutput.html#writeUTF(java.lang.String)

You should consider also reading about Modified UTF-8
http://java.sun.com/javase/6/docs/api/java/io/DataInput.html#modified-utf-8

Second, the reason for which the file "names.dat" appears different in
different
text editors is beacause each text editor encodes in the character
encoding
of their choice, and the choice largely depends on the conventions
used by
the system software. That is why you get strange symbols in notepad+
+,
jEdit, notepad, and so on.

Hope this helps you.

On Nov 28, 7:15 am, Programerz <rubyharton...@gmail.com> wrote:
> Thank you for the help,
>
> I would like to ask about the output of the "names.dat"
>
> the java output is:
>
> John Doe
> Jane Fonda
> Farrah Fawcett
> Keira Knightley
> Johnny Cash
> Another data
>
> However, when I open the "names.dat" with notepad, it shows:
>
>   John Doe
> Jane Fonda  Farrah Fawcett  Keira Knightley  Johnny Cash  Another data
>
> It has a space and some strange symbols at each of the beginning of
> the names
> ex:"' ''s'Farrah Fawcett"
>
> ' ' : Space
> 's' : Strange Symbol
>
> I don't know why the symbol did not appear at this email.
>
> I try to open at notepad++ :
>
> ' ' : "NUL"
> 's' : "BS","SO","SI","VT","FF"
>
> What are these means?

-- 
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to