Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Must end with null?  RSS feed

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all;
1. Assignment says

All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII.


Is that means while we are writing to the file we need to end a field with null, if less than the maximum length for the field?
2. Also I am using

writeBytes(str);


to write to the file. Is that means my character encoding is 8 bit US ASCII.
Thanks in advance
Roy.
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Roy Augustine:
Hi all;
1. Assignment says


All numeric values are stored in the header information use the formats of the DataInputStream and DataOutputStream classes. All text values, and all fields (which are text only), contain only 8 bit characters, null terminated if less than the maximum length for the field. The character encoding is 8 bit US ASCII.



Is that means while we are writing to the file we need to end a field with null, if less than the maximum length for the field?

Yes. You can either terminate it with null, or pad the rest of the field with space.

2. Also I am using


writeBytes(str);


to write to the file. Is that means my character encoding is 8 bit US ASCII.

It does'n mean any US-ASCII character encoding, probably it may use the default operating system encoding. There is no mention about any encoding for the above method in the API. You may want to search here for "Null Termination" and "character encoding is 8 bit US ASCII". You will get a couple of threads for one and many threads for other which are very useful and makes all clear regarding this encoding and null termination issue.

Thanks in advance
Roy.


Good Luck
 
Ranch Hand
Posts: 619
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roy,
Take a look at the String class, specifically

Also take a look at java.nio.charset.Charset (especially Standard charsets).
 
Roy Augustine
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks both for your help. I am going through different threads now. It look like that will help me. I am sorry I didn't search before posting.
Regards
Roy.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!