-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0
-
x86
-
solaris_8
Name: nt126004 Date: 12/02/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :SunOS xtreme 5.8
Generic_108528-14 sun4u sparc SUNW,Ultra-Enterprise
A DESCRIPTION OF THE PROBLEM :
The Javadoc for the second parameter
of "FileInputStream.read(byte[] b, int off, int len)" reads:
off - the start offset of the data.
However, the second parameter "off" is not the start offset
of the data. The data offset is automatically kept track
of by this method and each subsequent call to the method
starts were the last left off. The second parameter "off"
is actually the offset to the first parameter (byte[] b).
InputStream.read(byte[] b, int off, int len) reads :
off - the start offset in array b at which the data is written.
Since FileInputStream.read says "This method simply performs in.read(b, off, len) and returns the result.", the documentation should be the
same.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Based on the Javadoc I initially expected the method to
start reading the data at "off". However, the actual
results are that each call to the read method starts with
where the previous read ended. While this issue doesn't
technically impact the user it does slow progress by
creating confusion regarding the method.
The Javadoc should simply be changed to:
off - the start offset of the buffer.
REPRODUCIBILITY :
This bug can be reproduced always.
(Review ID: 167291)
======================================================================
- duplicates
-
JDK-4150728 (spec) {Data,}InputStream.read(byte[], int, int) - spec of offset argument confusing
-
- Resolved
-