Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Best way to read binary data?
- From: uddipan@xxxxxxxxxxxxxxxx (Uddipan Bagchi)
- Subject: Best way to read binary data?
- Date: Fri, 25 Dec 1998 10:30:53 +0530
> I will need to convert the bytes in that input stream into native Java types > like long and int. DataInputStream and ObjectInputStream provide methods that do just this. > Ideally, I'd like to create objects from parts of the > data. E.g., I might want to convert 20 bytes comprising an IP header into > an IP object. If you put an Object (understood as being distinct from just a stream of bytes) into the a byte stream using writeObject(Object) method of ObjectOutputStream, then you can read it back using readObject() method of ObjectInputStream. If it hasn't been written using writeObject(Object), and instead is written as a sequence of bytes reflecting some state of the object, then you would have to construct a new object after gathering the state of the object with consecutive reads using the readXXX() methods of ObjectInputStream. HIH. - Uddipan. --- To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
- Prev by Date: Java LaTeX Editor
- Previous by thread: Java LaTeX Editor
- Index(es):