• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

US-ASCII and File access

 
Radi Hadzhiyski
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)?
 
Anne Crace
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use RandomAccessFile and "ISO-8859-1" for my encoding.
 
Gert-Jan den Besten
Ranch Hand
Posts: 56
Java Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Roel De Nijs
Sheriff
Posts: 10204
129
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic