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: 4074338
Votes 0
Synopsis RandomAccessFile.writeBytes(String) is woefully ineffecient
Category java:classes_io
Reported Against 1.1.3
Release Fixed 1.1.6, 1.2(1.2beta3) (Bug ID:2016654)
State 11-Closed, Verified, request for enhancement
Priority: 4-Low
Related Bugs 4137835
Submit Date 26-AUG-1997
Description
RandomAccessFile.writeBytes(String) takes a string out writes it out in
bytes. What it neglects to say is it will write each byte out one-by-one.
This caused a performance problem on our machine. Its better to generate
your own byte array from string and then use RandomAccessFile.write(bytebuffer)

Some example truss output

23173:	read(8, "CAFEBABE\003\0 -\094\b\0".., 3203)	= 3203
23173:	brk(0x001749E8)					= 0
23173:	brk(0x001769E8)					= 0
23173:	write(17, " R", 1)				= 1
23173:	write(17, " e", 1)				= 1
23173:	write(17, " p", 1)				= 1
23173:	write(17, " l", 1)				= 1
23173:	write(17, " i", 1)				= 1
23173:	write(17, " e", 1)				= 1
23173:	write(17, " d", 1)				= 1
23173:	write(17, " :", 1)				= 1
23173:	write(17, "  ", 1)				= 1
Work Around
N/A
Evaluation
This method has been improved by buffering the bytes to be written and making a single call to the underlying write method.

The same technique has also been applied to writeChars(String).


  xxxxx@xxxxx   1997-11-24
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang