This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes US-ASCII and File access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "US-ASCII and File access" Watch "US-ASCII and File access" New topic
Author

US-ASCII and File access

Radi Hadzhiyski
Ranch Hand

Joined: Jun 30, 2009
Posts: 47
Hi everyone,


I have the following in my assignment:

1.
All numeric values are stored in the header information use the formats of the
DataInputStream and DataOutputStream classes.


2.
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.


so:

1. because US-ASCII is only 7 bit, i think that i should take the ISO-8859-1 or the UTF-8?
2. because DataInputStream extends InputStream , should i take for my database file obligative the DataInputStream
or the FileInputStream extends InputStream
or can i take RandomAccessFile too (RandomAccessFile implements DataInput and
DataInputStrem implements also DataInput)?


SCJP 1.6 (91%), SCJD
Anne Crace
Ranch Hand

Joined: Aug 29, 2005
Posts: 223
I use RandomAccessFile and "ISO-8859-1" for my encoding.


SCJP, SCJD
Gert-Jan den Besten
Ranch Hand

Joined: May 02, 2008
Posts: 56

Radi Hadzhiyski wrote:1. because US-ASCII is only 7 bit, i think that i should take the ISO-8859-1 or the UTF-8?

I explicitly used the US-ASCII encoding. At work I'm a middleware developer and I have to be very picky (more than needed for this assignment) about codepages/charactersets/encodings...

Radi Hadzhiyski wrote:2. because DataInputStream extends InputStream , should i take for my database file obligative the DataInputStream
or the FileInputStream extends InputStream
or can i take RandomAccessFile too (RandomAccessFile implements DataInput and
DataInputStrem implements also DataInput)?

The formats named in the description matches the formats of the RandomAccessFile. You're safe to use the RAF.


SCJP 5; SCJD; SCWCD 5.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5216
    
  12

Hi Radi,

Used the same things like Anne: RAF (think that every scjd'er is using that one) and ISO-8859-1 as character encoding.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: US-ASCII and File access