how to read long[] from data input stream ?

J

Jimmy Zhang

I am looking for ways to read data into a long array from data input stream
directly. I feel that wrapping Fileinputstream
using DataInputStream filter is kinda inefficient, if there is a way to let
the datainputstream to arrange 8 bytes into a long directly, it wouild be
really nice.

Any suggestions on how to realize this?

Thanks,
Jimmy
 
M

Marco Schmidt

Jimmy Zhang:
I am looking for ways to read data into a long array from data input stream
directly. I feel that wrapping Fileinputstream
using DataInputStream filter is kinda inefficient, if there is a way to let
the datainputstream to arrange 8 bytes into a long directly, it wouild be
really nice.

Why do you think it's not efficient? It's a normal approach in Java to
wrap I/O objects into other I/O objects. Just try the
DataInputStream/FileInputStream combination. However, make sure you
also include a buffering stream:

DataInput in = new DataInputStream(new BufferedInputStream(new
FileInputStream("file.dat")));
long l1 = in.readLong();
long l2 = in.readLong();
....

Regards,
Marco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top