< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 166      * is thrown.
 167      *
 168      * <li>An I/O error occurs, in
 169      * which case an {@code IOException} other
 170      * than {@code EOFException} is thrown.
 171      * </ul>
 172      * <p>
 173      * If {@code b} is {@code null},
 174      * a {@code NullPointerException} is thrown.
 175      * If {@code b.length} is zero, then
 176      * no bytes are read. Otherwise, the first
 177      * byte read is stored into element {@code b[0]},
 178      * the next one into {@code b[1]}, and
 179      * so on.
 180      * If an exception is thrown from
 181      * this method, then it may be that some but
 182      * not all bytes of {@code b} have been
 183      * updated with data from the input stream.
 184      *
 185      * @param     b   the buffer into which the data is read.
 186      * @exception  EOFException  if this stream reaches the end before reading

 187      *               all the bytes.
 188      * @exception  IOException   if an I/O error occurs.
 189      */
 190     void readFully(byte b[]) throws IOException;
 191 
 192     /**
 193      *
 194      * Reads {@code len}
 195      * bytes from
 196      * an input stream.
 197      * <p>
 198      * This method
 199      * blocks until one of the following conditions
 200      * occurs:
 201      * <ul>
 202      * <li>{@code len} bytes
 203      * of input data are available, in which case
 204      * a normal return is made.
 205      *
 206      * <li>End of file
 207      * is detected, in which case an {@code EOFException}
 208      * is thrown.


 210      * <li>An I/O error occurs, in
 211      * which case an {@code IOException} other
 212      * than {@code EOFException} is thrown.
 213      * </ul>
 214      * <p>
 215      * If {@code b} is {@code null},
 216      * a {@code NullPointerException} is thrown.
 217      * If {@code off} is negative, or {@code len}
 218      * is negative, or {@code off+len} is
 219      * greater than the length of the array {@code b},
 220      * then an {@code IndexOutOfBoundsException}
 221      * is thrown.
 222      * If {@code len} is zero,
 223      * then no bytes are read. Otherwise, the first
 224      * byte read is stored into element {@code b[off]},
 225      * the next one into {@code b[off+1]},
 226      * and so on. The number of bytes read is,
 227      * at most, equal to {@code len}.
 228      *
 229      * @param     b   the buffer into which the data is read.
 230      * @param off  an int specifying the offset into the data.
 231      * @param len  an int specifying the number of bytes to read.
 232      * @exception  EOFException  if this stream reaches the end before reading




 233      *               all the bytes.
 234      * @exception  IOException   if an I/O error occurs.
 235      */
 236     void readFully(byte b[], int off, int len) throws IOException;
 237 
 238     /**
 239      * Makes an attempt to skip over
 240      * {@code n} bytes
 241      * of data from the input
 242      * stream, discarding the skipped bytes. However,
 243      * it may skip
 244      * over some smaller number of
 245      * bytes, possibly zero. This may result from
 246      * any of a
 247      * number of conditions; reaching
 248      * end of file before {@code n} bytes
 249      * have been skipped is
 250      * only one possibility.
 251      * This method never throws an {@code EOFException}.
 252      * The actual
 253      * number of bytes skipped is returned.
 254      *


   1 /*
   2  * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 166      * is thrown.
 167      *
 168      * <li>An I/O error occurs, in
 169      * which case an {@code IOException} other
 170      * than {@code EOFException} is thrown.
 171      * </ul>
 172      * <p>
 173      * If {@code b} is {@code null},
 174      * a {@code NullPointerException} is thrown.
 175      * If {@code b.length} is zero, then
 176      * no bytes are read. Otherwise, the first
 177      * byte read is stored into element {@code b[0]},
 178      * the next one into {@code b[1]}, and
 179      * so on.
 180      * If an exception is thrown from
 181      * this method, then it may be that some but
 182      * not all bytes of {@code b} have been
 183      * updated with data from the input stream.
 184      *
 185      * @param   b   the buffer into which the data is read.
 186      * @throws  NullPointerException if {@code b} is {@code null}.
 187      * @throws  EOFException  if this stream reaches the end before reading
 188      *          all the bytes.
 189      * @throws  IOException   if an I/O error occurs.
 190      */
 191     void readFully(byte b[]) throws IOException;
 192 
 193     /**
 194      *
 195      * Reads {@code len}
 196      * bytes from
 197      * an input stream.
 198      * <p>
 199      * This method
 200      * blocks until one of the following conditions
 201      * occurs:
 202      * <ul>
 203      * <li>{@code len} bytes
 204      * of input data are available, in which case
 205      * a normal return is made.
 206      *
 207      * <li>End of file
 208      * is detected, in which case an {@code EOFException}
 209      * is thrown.


 211      * <li>An I/O error occurs, in
 212      * which case an {@code IOException} other
 213      * than {@code EOFException} is thrown.
 214      * </ul>
 215      * <p>
 216      * If {@code b} is {@code null},
 217      * a {@code NullPointerException} is thrown.
 218      * If {@code off} is negative, or {@code len}
 219      * is negative, or {@code off+len} is
 220      * greater than the length of the array {@code b},
 221      * then an {@code IndexOutOfBoundsException}
 222      * is thrown.
 223      * If {@code len} is zero,
 224      * then no bytes are read. Otherwise, the first
 225      * byte read is stored into element {@code b[off]},
 226      * the next one into {@code b[off+1]},
 227      * and so on. The number of bytes read is,
 228      * at most, equal to {@code len}.
 229      *
 230      * @param   b    the buffer into which the data is read.
 231      * @param   off  an int specifying the offset in the data array {@code b}.
 232      * @param   len  an int specifying the number of bytes to read.
 233      * @throws  NullPointerException if {@code b} is {@code null}.
 234      * @throws  IndexOutOfBoundsException if {@code off} is negative,
 235      *          {@code len} is negative, or {@code len} is greater than
 236      *          {@code b.length - off}.
 237      * @throws  EOFException  if this stream reaches the end before reading
 238      *          all the bytes.
 239      * @throws  IOException   if an I/O error occurs.
 240      */
 241     void readFully(byte b[], int off, int len) throws IOException;
 242 
 243     /**
 244      * Makes an attempt to skip over
 245      * {@code n} bytes
 246      * of data from the input
 247      * stream, discarding the skipped bytes. However,
 248      * it may skip
 249      * over some smaller number of
 250      * bytes, possibly zero. This may result from
 251      * any of a
 252      * number of conditions; reaching
 253      * end of file before {@code n} bytes
 254      * have been skipped is
 255      * only one possibility.
 256      * This method never throws an {@code EOFException}.
 257      * The actual
 258      * number of bytes skipped is returned.
 259      *


< prev index next >