jdk/src/java.base/share/classes/java/io/RandomAccessFile.java
changeset 37591 b71bda3ce058
parent 32033 bf24e33c7919
child 38466 4bcf5f2bb351
equal deleted inserted replaced
37590:8501202dc35b 37591:b71bda3ce058
     1 /*
     1 /*
     2  * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   416      * array, starting at the current file pointer. This method reads
   416      * array, starting at the current file pointer. This method reads
   417      * repeatedly from the file until the requested number of bytes are
   417      * repeatedly from the file until the requested number of bytes are
   418      * read. This method blocks until the requested number of bytes are
   418      * read. This method blocks until the requested number of bytes are
   419      * read, the end of the stream is detected, or an exception is thrown.
   419      * read, the end of the stream is detected, or an exception is thrown.
   420      *
   420      *
   421      * @param      b   the buffer into which the data is read.
   421      * @param   b   the buffer into which the data is read.
   422      * @exception  EOFException  if this file reaches the end before reading
   422      * @throws  NullPointerException if {@code b} is {@code null}.
   423      *               all the bytes.
   423      * @throws  EOFException  if this file reaches the end before reading
   424      * @exception  IOException   if an I/O error occurs.
   424      *              all the bytes.
       
   425      * @throws  IOException   if an I/O error occurs.
   425      */
   426      */
   426     public final void readFully(byte b[]) throws IOException {
   427     public final void readFully(byte b[]) throws IOException {
   427         readFully(b, 0, b.length);
   428         readFully(b, 0, b.length);
   428     }
   429     }
   429 
   430 
   432      * array, starting at the current file pointer. This method reads
   433      * array, starting at the current file pointer. This method reads
   433      * repeatedly from the file until the requested number of bytes are
   434      * repeatedly from the file until the requested number of bytes are
   434      * read. This method blocks until the requested number of bytes are
   435      * read. This method blocks until the requested number of bytes are
   435      * read, the end of the stream is detected, or an exception is thrown.
   436      * read, the end of the stream is detected, or an exception is thrown.
   436      *
   437      *
   437      * @param      b     the buffer into which the data is read.
   438      * @param   b     the buffer into which the data is read.
   438      * @param      off   the start offset of the data.
   439      * @param   off   the start offset into the data array {@code b}.
   439      * @param      len   the number of bytes to read.
   440      * @param   len   the number of bytes to read.
   440      * @exception  EOFException  if this file reaches the end before reading
   441      * @throws  NullPointerException if {@code b} is {@code null}.
   441      *               all the bytes.
   442      * @throws  IndexOutOfBoundsException if {@code off} is negative,
   442      * @exception  IOException   if an I/O error occurs.
   443      *                {@code len} is negative, or {@code len} is greater than
       
   444      *                {@code b.length - off}.
       
   445      * @throws  EOFException  if this file reaches the end before reading
       
   446      *                all the bytes.
       
   447      * @throws  IOException   if an I/O error occurs.
   443      */
   448      */
   444     public final void readFully(byte b[], int off, int len) throws IOException {
   449     public final void readFully(byte b[], int off, int len) throws IOException {
   445         int n = 0;
   450         int n = 0;
   446         do {
   451         do {
   447             int count = this.read(b, off + n, len - n);
   452             int count = this.read(b, off + n, len - n);