Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with DataInputStream & DataOutputStream

 
Jose Perozo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody, i am new here, i am working on the URLyBird project, i don't have any problem when reading the database file, in fact i already implemented the read method using DataInputStream and it works fine! my problem begins when i try to implement the update method, it would be easy to solve if i were allow to use the RandomAccessFile, but i think i can not use it, please see my instruction, and tell me if i am obligated to use DataInputStream and DataOutputStream classes, and if so please, please tell how to deal with it when implementing the update method.

My instructions says this:

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.

SCJP
SCJD (in progress)
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy, my buddy.

Originally posted by Jose Perozo:
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.


This instruction simply says the headers (the info about the length of each record, the size of each field, etc) use the format of DataInputStream and DataOutputStream. But, we are free to use the RandomAccessFile. And also, remember to use the 8 bit US ASCII character encoding when saving/reading from the database. For example, you can do something like this:

String hotelName = new String(buffer, "US-ASCII");

where buffer is the array of bytes that you just read from the database (using the RandomAccessFile class).
 
Jose Perozo
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks! i was very confuse about it. i thought i was forced to use DataInputStream. RandomAccessFile is easier, as everybody usually does, i'll work with it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic