jdk/src/share/classes/java/io/DataInput.java
author smarks
Mon, 20 Dec 2010 13:47:04 -0800
changeset 7803 56bc97d69d93
parent 5506 202f599c92aa
child 11676 7e75ec031b97
permissions -rw-r--r--
6880112: Project Coin: Port JDK core library code to use diamond operator Reviewed-by: darcy, lancea, alanb, briangoetz, mduigou, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.io;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The <code>DataInput</code> interface provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * for reading bytes from a binary stream and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * reconstructing from them data in any of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * the Java primitive types. There is also
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * facility for reconstructing a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * from data in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <a href="#modified-utf-8">modified UTF-8</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * It is generally true of all the reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * routines in this interface that if end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * file is reached before the desired number
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * of bytes has been read, an <code>EOFException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * (which is a kind of <code>IOException</code>)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * is thrown. If any byte cannot be read for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * any reason other than end of file, an <code>IOException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * other than <code>EOFException</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * thrown. In particular, an <code>IOException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * may be thrown if the input stream has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * closed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * <h4><a name="modified-utf-8">Modified UTF-8</a></h4>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Implementations of the DataInput and DataOutput interfaces represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Unicode strings in a format that is a slight modification of UTF-8.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * (For information regarding the standard UTF-8 format, see section
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <i>3.9 Unicode Encoding Forms</i> of <i>The Unicode Standard, Version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * 4.0</i>).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Note that in the following tables, the most significant bit appears in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * far left-hand column.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * All characters in the range <code>'&#92;u0001'</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <code>'&#92;u007F'</code> are represented by a single byte:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *   <table border="1" cellspacing="0" cellpadding="8" width="50%"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *          summary="Bit values and bytes">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *       <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *       <th id="bit">Bit Values</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *       <th id="byte1">Byte 1</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *             <td width="12%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *             <td colspan="7"><center>bits 6-0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *   </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * The null character <code>'&#92;u0000'</code> and characters in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * range <code>'&#92;u0080'</code> to <code>'&#92;u07FF'</code> are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * represented by a pair of bytes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *   <table border="1" cellspacing="0" cellpadding="8" width="50%"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *          summary="Bit values and bytes">
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *       <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *       <th id="bit">Bit Values</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *       <th id="byte1">Byte 1</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *             <td width="13%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *             <td width="12%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *             <td colspan="5"><center>bits 10-6</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *       <th id="byte2">Byte 2</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *             <td width="13%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 *             <td colspan="6"><center>bits 5-0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *   </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *  </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * <br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * <code>char</code> values in the range <code>'&#92;u0800'</code> to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 * <code>'&#92;uFFFF'</code> are represented by three bytes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 * <blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *   <table border="1" cellspacing="0" cellpadding="8" width="50%"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *          summary="Bit values and bytes">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *       <td></td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *       <th id="bit">Bit Values</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 *       <th id="byte1">Byte 1</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 *             <td width="13%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 *             <td width="13%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
 *             <td colspan="4"><center>bits 15-12</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 *       <th id="byte2">Byte 2</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 *             <td width="13%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *             <td colspan="6"><center>bits 11-6</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *     <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *       <th id="byte3">Byte 3</th>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *       <td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *         <table border="1" cellspacing="0" width="100%">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *           <tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *             <td width="12%"><center>1</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *             <td width="13%"><center>0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 *             <td colspan="6"><center>bits 5-0</center>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
 *           </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
 *         </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
 *       </td>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 *   </table>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 *  </blockquote>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 * The differences between this format and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 * standard UTF-8 format are the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
 * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 * <li>The null byte <code>'&#92;u0000'</code> is encoded in 2-byte format
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 *     rather than 1-byte, so that the encoded strings never have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 *     embedded nulls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
 * <li>Only the 1-byte, 2-byte, and 3-byte formats are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
 * <li><a href="../lang/Character.html#unicode">Supplementary characters</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
 *     are represented in the form of surrogate pairs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
 * @author  Frank Yellin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
 * @see     java.io.DataInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
 * @see     java.io.DataOutput
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
 * @since   JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
interface DataInput {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Reads some bytes from an input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * stream and stores them into the buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * array <code>b</code>. The number of bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * read is equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * to the length of <code>b</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * This method blocks until one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * following conditions occurs:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * <li><code>b.length</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * bytes of input data are available, in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * case a normal return is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <li>End of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * file is detected, in which case an <code>EOFException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <li>An I/O error occurs, in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * which case an <code>IOException</code> other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * than <code>EOFException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * If <code>b</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * a <code>NullPointerException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * If <code>b.length</code> is zero, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * no bytes are read. Otherwise, the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * byte read is stored into element <code>b[0]</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * the next one into <code>b[1]</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * so on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * If an exception is thrown from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * this method, then it may be that some but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * not all bytes of <code>b</code> have been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * updated with data from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @param     b   the buffer into which the data is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    void readFully(byte b[]) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Reads <code>len</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * bytes from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * an input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * blocks until one of the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * occurs:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * <li><code>len</code> bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * of input data are available, in which case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * a normal return is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * <li>End of file
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * is detected, in which case an <code>EOFException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <li>An I/O error occurs, in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * which case an <code>IOException</code> other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * than <code>EOFException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * If <code>b</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * a <code>NullPointerException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * If <code>off</code> is negative, or <code>len</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * is negative, or <code>off+len</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * greater than the length of the array <code>b</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * then an <code>IndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * If <code>len</code> is zero,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * then no bytes are read. Otherwise, the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * byte read is stored into element <code>b[off]</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * the next one into <code>b[off+1]</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * and so on. The number of bytes read is,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * at most, equal to <code>len</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param     b   the buffer into which the data is read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @param off  an int specifying the offset into the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param len  an int specifying the number of bytes to read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    void readFully(byte b[], int off, int len) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * Makes an attempt to skip over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * <code>n</code> bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * of data from the input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * stream, discarding the skipped bytes. However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * it may skip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * over some smaller number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * bytes, possibly zero. This may result from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * any of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * number of conditions; reaching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * end of file before <code>n</code> bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * have been skipped is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * only one possibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * This method never throws an <code>EOFException</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * The actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * number of bytes skipped is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param      n   the number of bytes to be skipped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @return     the number of bytes actually skipped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    int skipBytes(int n) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Reads one input byte and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * <code>true</code> if that byte is nonzero,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * <code>false</code> if that byte is zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * This method is suitable for reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * the byte written by the <code>writeBoolean</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @return     the <code>boolean</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    boolean readBoolean() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * Reads and returns one input byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * The byte is treated as a signed value in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * the range <code>-128</code> through <code>127</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * This method is suitable for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * reading the byte written by the <code>writeByte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @return     the 8-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    byte readByte() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * Reads one input byte, zero-extends
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * it to type <code>int</code>, and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * the result, which is therefore in the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * through <code>255</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * This method is suitable for reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * the byte written by the <code>writeByte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * method of interface <code>DataOutput</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * if the argument to <code>writeByte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * was intended to be a value in the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * <code>0</code> through <code>255</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @return     the unsigned 8-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    int readUnsignedByte() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * Reads two input bytes and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * a <code>short</code> value. Let <code>a</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * be the first byte read and <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * be the second byte. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * <p><pre><code>(short)((a &lt;&lt; 8) | (b &amp; 0xff))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * is suitable for reading the bytes written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * by the <code>writeShort</code> method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @return     the 16-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    short readShort() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * Reads two input bytes and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * an <code>int</code> value in the range <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * through <code>65535</code>. Let <code>a</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * be the first byte read and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * be the second byte. The value returned is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * <p><pre><code>(((a &amp; 0xff) &lt;&lt; 8) | (b &amp; 0xff))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * This method is suitable for reading the bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * written by the <code>writeShort</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * of interface <code>DataOutput</code>  if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * the argument to <code>writeShort</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * was intended to be a value in the range
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * <code>0</code> through <code>65535</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @return     the unsigned 16-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    int readUnsignedShort() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * Reads two input bytes and returns a <code>char</code> value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * Let <code>a</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * be the first byte read and <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * be the second byte. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * returned is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * <p><pre><code>(char)((a &lt;&lt; 8) | (b &amp; 0xff))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * is suitable for reading bytes written by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * the <code>writeChar</code> method of interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @return     the <code>char</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    char readChar() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * Reads four input bytes and returns an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * <code>int</code> value. Let <code>a-d</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * be the first through fourth bytes read. The value returned is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * <p><pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * (((a &amp; 0xff) &lt;&lt; 24) | ((b &amp; 0xff) &lt;&lt; 16) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * &#32;((c &amp; 0xff) &lt;&lt; 8) | (d &amp; 0xff))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * This method is suitable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * for reading bytes written by the <code>writeInt</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @return     the <code>int</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    int readInt() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * Reads eight input bytes and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * a <code>long</code> value. Let <code>a-h</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * be the first through eighth bytes read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * The value returned is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * <p><pre> <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * (((long)(a &amp; 0xff) &lt;&lt; 56) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *  ((long)(b &amp; 0xff) &lt;&lt; 48) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *  ((long)(c &amp; 0xff) &lt;&lt; 40) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *  ((long)(d &amp; 0xff) &lt;&lt; 32) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *  ((long)(e &amp; 0xff) &lt;&lt; 24) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *  ((long)(f &amp; 0xff) &lt;&lt; 16) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *  ((long)(g &amp; 0xff) &lt;&lt;  8) |
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *  ((long)(h &amp; 0xff)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * This method is suitable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * for reading bytes written by the <code>writeLong</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * @return     the <code>long</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    long readLong() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * Reads four input bytes and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * a <code>float</code> value. It does this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * by first constructing an <code>int</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * value in exactly the manner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * of the <code>readInt</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * method, then converting this <code>int</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * value to a <code>float</code> in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * exactly the manner of the method <code>Float.intBitsToFloat</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * This method is suitable for reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * bytes written by the <code>writeFloat</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @return     the <code>float</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    float readFloat() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * Reads eight input bytes and returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * a <code>double</code> value. It does this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * by first constructing a <code>long</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * value in exactly the manner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * of the <code>readlong</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * method, then converting this <code>long</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * value to a <code>double</code> in exactly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * the manner of the method <code>Double.longBitsToDouble</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * This method is suitable for reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * bytes written by the <code>writeDouble</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * method of interface <code>DataOutput</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @return     the <code>double</code> value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    double readDouble() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * Reads the next line of text from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * It reads successive bytes, converting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * each byte separately into a character,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * until it encounters a line terminator or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * file; the characters read are then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * returned as a <code>String</code>. Note
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * that because this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * method processes bytes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * it does not support input of the full Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * character set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * If end of file is encountered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * before even one byte can be read, then <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * is returned. Otherwise, each byte that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * read is converted to type <code>char</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * by zero-extension. If the character <code>'\n'</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * is encountered, it is discarded and reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * ceases. If the character <code>'\r'</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * is encountered, it is discarded and, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * the following byte converts &#32;to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * character <code>'\n'</code>, then that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * discarded also; reading then ceases. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * end of file is encountered before either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * of the characters <code>'\n'</code> and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * <code>'\r'</code> is encountered, reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * ceases. Once reading has ceased, a <code>String</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * is returned that contains all the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * read and not discarded, taken in order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * Note that every character in this string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * will have a value less than <code>&#92;u0100</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * that is, <code>(char)256</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @return the next line of text from the input stream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     *         or <CODE>null</CODE> if the end of file is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *         encountered before a byte can be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    String readLine() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * Reads in a string that has been encoded using a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * <a href="#modified-utf-8">modified UTF-8</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * The general contract of <code>readUTF</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * is that it reads a representation of a Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * character string encoded in modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * UTF-8 format; this string of characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * is then returned as a <code>String</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * First, two bytes are read and used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * construct an unsigned 16-bit integer in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * exactly the manner of the <code>readUnsignedShort</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * method . This integer value is called the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * <i>UTF length</i> and specifies the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * of additional bytes to be read. These bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * are then converted to characters by considering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * them in groups. The length of each group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * is computed from the value of the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * byte of the group. The byte following a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * group, if any, is the first byte of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * next group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * If the first byte of a group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * matches the bit pattern <code>0xxxxxxx</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * (where <code>x</code> means "may be <code>0</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * or <code>1</code>"), then the group consists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * of just that byte. The byte is zero-extended
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * to form a character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * If the first byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * of a group matches the bit pattern <code>110xxxxx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * then the group consists of that byte <code>a</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * and a second byte <code>b</code>. If there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * is no byte <code>b</code> (because byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * <code>a</code> was the last of the bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * to be read), or if byte <code>b</code> does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * not match the bit pattern <code>10xxxxxx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * then a <code>UTFDataFormatException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * is thrown. Otherwise, the group is converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * to the character:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * <pre><code>(char)(((a&amp; 0x1F) &lt;&lt; 6) | (b &amp; 0x3F))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * If the first byte of a group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * matches the bit pattern <code>1110xxxx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * then the group consists of that byte <code>a</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * and two more bytes <code>b</code> and <code>c</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * If there is no byte <code>c</code> (because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * byte <code>a</code> was one of the last
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * two of the bytes to be read), or either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * byte <code>b</code> or byte <code>c</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * does not match the bit pattern <code>10xxxxxx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * then a <code>UTFDataFormatException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * is thrown. Otherwise, the group is converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * to the character:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * <pre><code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * (char)(((a &amp; 0x0F) &lt;&lt; 12) | ((b &amp; 0x3F) &lt;&lt; 6) | (c &amp; 0x3F))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * </code></pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * If the first byte of a group matches the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * pattern <code>1111xxxx</code> or the pattern
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * <code>10xxxxxx</code>, then a <code>UTFDataFormatException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * If end of file is encountered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * at any time during this entire process,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * then an <code>EOFException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * After every group has been converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * a character by this process, the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * are gathered, in the same order in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * their corresponding groups were read from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * the input stream, to form a <code>String</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * which is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * The <code>writeUTF</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * method of interface <code>DataOutput</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * may be used to write data that is suitable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * for reading by this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @return     a Unicode string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * @exception  EOFException            if this stream reaches the end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     *               before reading all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @exception  IOException             if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * @exception  UTFDataFormatException  if the bytes do not represent a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *               valid modified UTF-8 encoding of a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    String readUTF() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
}