< prev index next >
test/jdk/java/io/ByteArrayInputStream/ReadAllReadNTransferTo.java
Print this page
@@ -43,34 +43,34 @@
private static Random random = RandomFactory.getRandom();
public static void main(String... args) throws IOException {
byte[] buf = new byte[SIZE];
random.nextBytes(buf);
- int offset = random.nextInt(SIZE/2);
- int length = random.nextInt(SIZE - offset);
+ int position = random.nextInt(SIZE/2);
+ int size = random.nextInt(SIZE - position);
ByteArrayInputStream bais =
- new ByteArrayInputStream(buf, offset, length);
- int off = random.nextInt(length/2);
- int len = random.nextInt(length - off);
+ new ByteArrayInputStream(buf, position, size);
+ int off = random.nextInt(size/2);
+ int len = random.nextInt(size- off);
byte[] bN = new byte[off + len];
if (bais.readNBytes(bN, off, len) != len) {
throw new RuntimeException("readNBytes return value");
}
if (!Arrays.equals(bN, off, off + len,
- buf, offset, offset + len)) {
+ buf, position, position + len)) {
throw new RuntimeException("readNBytes content");
}
byte[] bAll = bais.readAllBytes();
Objects.requireNonNull(bAll, "readAllBytes return value");
- if (bAll.length != length - len) {
+ if (bAll.length != size - len) {
throw new RuntimeException("readAllBytes return value length");
}
if (!Arrays.equals(bAll, 0, bAll.length,
- buf, offset + len, offset + len + bAll.length)) {
+ buf, position + len, position + len + bAll.length)) {
throw new RuntimeException("readAllBytes content");
}
// XXX transferTo()
bais = new ByteArrayInputStream(buf);
< prev index next >