|
Description
|
I have some files that contain information in the short integer format. I would like to recall the
data into arrays, but I see that you provide no functions in your java.io.RandomAccessFile class to handle
this type of transfer. To recall 30,000 short integers one at a time makes the program
extremely slow! If I recall the data as an array of bytes I then have to convert the data before it can be used as follows:
int i, j, k;
byte[] b = new byte[60000];
short[] s = new short[30000];
:
// read 60000 bytes from the file
:
j = 0;
for(i = 0; i < 30000; ++i) {
k = b[j+1];// make low byte to int
if(k < 0) k += 256;// make low byte positive
s[i] = (short)(((int)b[j]<<8)+k);
j += 2;
}
Are there plans for Java to supply better file handling functions, or are we stuck with byte file
transfers? As it is now my program is at least 10 times faster as a C/C++ program.
Please add better RandomAccessFile handling functions...
Tim
(Review ID: 33715)
======================================================================
|