Hi, I am trying to use the FileReader with the DataInputStream to read in characters from a text file (ex .4RDE.2CS.9WD ). I've never actually worked with files before, so I'm completely clueless on how to do it, or if it can be done the way I am trying to do it.
I am using the '.' as a dilimiter, when the byte is a '.' I want to skip to the next byte and use that as a counter. The byte after the counter is the byte I want to repeat based on the counter value.
So for exampe .4R would be RRRR (4R's) and the rest would be DECCSWWWWWWWWWD
Some problems I am having are: - What encoding should I save my test file as? ASCI, Unicode, UTF-8? - If I try to use readChar() on the first character it returns a '?' character, but if I use readByte() it returns back a '.'? Any help is appreciated, thanks.
This is the code I am using:
Joined: Jan 29, 2003
I've never used DataInputStream but it looks as though it's only going to work with a file that was written by DataOutputStream or happens to have exactly the right binary format. readInt Doc You may have to use an inputstream, read one char at a time and parse the length char into an int.
Your compression scheme is very familiar. I've done it with a 2 or 3 character length field and gotten very good compression on fixed length COBOL fields padded with zeros & spaces. Be sure to handle a "." in your data!
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Jul 02, 2006
At the moment I'm using the FileInputStream to try and read it in one one char or short at a time, I'm not sure if that's the one I should be using with the DataInputStream. Anything that works is fine by me