Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4205639
Votes 2
Synopsis java.io.RandomAccessFile: Add methods that read whole arrays of primitive type
Category java:classes_io
Reported Against 1.1.6
Release Fixed
State 3-Accepted, request for enhancement
Priority: 4-Low
Related Bugs
Submit Date 25-JAN-1999
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)
======================================================================
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   

Submitted On 03-MAY-1999
dubey
I too agree with this. File handling in Java is not efficient. Is there any way
by which one can change line while appending a file opened in 'rw' mode?


Submitted On 18-JUL-2004
ak64
see <a href="http://uio.imagero.com">unified io</a>



PLEASE NOTE: JDK6 is formerly known as Project Mustang