JDK-4074338 : RandomAccessFile.writeBytes(String) is woefully ineffecient
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.3
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-08-26
  • Updated: 1998-08-14
  • Resolved: 1998-08-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other Other
1.1.6 1.1.6Fixed 1.2.0Fixed
Related Reports
Relates :  
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

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.1.6 1.2beta3 INTEGRATED IN: 1.1.6 1.2beta3 VERIFIED IN: 1.1.6
14-06-2004

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). deepa.viswanathan@eng 1997-11-24
24-11-1997