src/java.base/share/classes/java/io/RandomAccessFile.java

Print this page
rev 14187 : 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
Summary: Clarify and expand specification of ObjectInputStream.read(byte[],int,int) and both variants of {DataInput,DataInputStream,ObjectInputStream,RandomAccessfile}.readFully().
Reviewed-by: XXX

*** 1,7 **** /* ! * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 417,429 **** * repeatedly from the file until the requested number of bytes are * read. This method blocks until the requested number of bytes are * read, the end of the stream is detected, or an exception is thrown. * * @param b the buffer into which the data is read. ! * @exception EOFException if this file reaches the end before reading * all the bytes. ! * @exception IOException if an I/O error occurs. */ public final void readFully(byte b[]) throws IOException { readFully(b, 0, b.length); } --- 417,430 ---- * repeatedly from the file until the requested number of bytes are * read. This method blocks until the requested number of bytes are * read, the end of the stream is detected, or an exception is thrown. * * @param b the buffer into which the data is read. ! * @throws NullPointerException If {@code b} is {@code null} ! * @throws EOFException if this file reaches the end before reading * all the bytes. ! * @throws IOException if an I/O error occurs. */ public final void readFully(byte b[]) throws IOException { readFully(b, 0, b.length); }
*** 433,447 **** * repeatedly from the file until the requested number of bytes are * read. This method blocks until the requested number of bytes are * read, the end of the stream is detected, or an exception is thrown. * * @param b the buffer into which the data is read. ! * @param off the start offset of the data. * @param len the number of bytes to read. ! * @exception EOFException if this file reaches the end before reading * all the bytes. ! * @exception IOException if an I/O error occurs. */ public final void readFully(byte b[], int off, int len) throws IOException { int n = 0; do { int count = this.read(b, off + n, len - n); --- 434,452 ---- * repeatedly from the file until the requested number of bytes are * read. This method blocks until the requested number of bytes are * read, the end of the stream is detected, or an exception is thrown. * * @param b the buffer into which the data is read. ! * @param off the start offset into the data array {@code b}. * @param len the number of bytes to read. ! * @throws NullPointerException If {@code b} is {@code null}. ! * @throws IndexOutOfBoundsException If {@code off} is negative, ! * {@code len} is negative, or {@code len} is greater than ! * {@code b.length - off} ! * @throws EOFException if this file reaches the end before reading * all the bytes. ! * @throws IOException if an I/O error occurs. */ public final void readFully(byte b[], int off, int len) throws IOException { int n = 0; do { int count = this.read(b, off + n, len - n);