File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Must end with null? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Must end with null?" Watch "Must end with null?" New topic
Author

Must end with null?

Roy Augustine
Ranch Hand

Joined: Jul 08, 2003
Posts: 30
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.
Satish Avadhanam
Ranch Hand

Joined: Aug 12, 2003
Posts: 697
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
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Roy,
Take a look at the String class, specifically

Also take a look at java.nio.charset.Charset (especially Standard charsets).


Regards, George
SCJP, SCJD, SCWCD, SCBCD
Roy Augustine
Ranch Hand

Joined: Jul 08, 2003
Posts: 30
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Must end with null?