src/java.base/share/classes/java/io/DataInput.java
author bpb
Thu, 06 Jun 2019 08:11:25 -0700
changeset 55259 61fff1345ee6
parent 54206 003cc64366da
child 58242 94bb65cb37d3
permissions -rw-r--r--
8219992: Correct the documentation of PrintWriter to refer System.lineSeparator Reviewed-by: darcy, lancea, rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
54206
003cc64366da 8220249: fix headings in java.compiler
jjg
parents: 47216
diff changeset
     2
 * Copyright (c) 1995, 2019, 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
/**
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    29
 * The {@code DataInput} interface provides
2
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
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    34
 * facility for reconstructing a {@code String}
2
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
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    42
 * of bytes has been read, an {@code EOFException}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    43
 * (which is a kind of {@code IOException})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * is thrown. If any byte cannot be read for
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    45
 * any reason other than end of file, an {@code IOException}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    46
 * other than {@code EOFException} is
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
    47
 * thrown. In particular, an {@code IOException}
2
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
 *
54206
003cc64366da 8220249: fix headings in java.compiler
jjg
parents: 47216
diff changeset
    51
 * <h2><a id="modified-utf-8">Modified UTF-8</a></h2>
2
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
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    57
 * 4.0</i>)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    59
 * <ul>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    60
 * <li>Characters in the range {@code '\u005Cu0001'} to
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    61
 *         {@code '\u005Cu007F'} are represented by a single byte.
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    62
 * <li>The null character {@code '\u005Cu0000'} and characters
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    63
 *         in the range {@code '\u005Cu0080'} to {@code '\u005Cu07FF'} are
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    64
 *         represented by a pair of bytes.
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    65
 * <li>Characters in the range {@code '\u005Cu0800'}
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    66
 *         to {@code '\u005CuFFFF'} are represented by three bytes.
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    67
 * </ul>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    68
 *
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    69
 *   <table class="plain" style="margin-left:2em;">
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    70
 *     <caption>Encoding of UTF-8 values</caption>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    71
 *     <thead>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    73
 *       <th scope="col" rowspan="2">Value</th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    74
 *       <th scope="col" rowspan="2">Byte</th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    75
 *       <th scope="col" colspan="8" id="bit_a">Bit Values</th>
19029
30c64a024c86 8020426: Fix doclint accessibility issues in java.io
juh
parents: 18786
diff changeset
    76
 *     </tr>
30c64a024c86 8020426: Fix doclint accessibility issues in java.io
juh
parents: 18786
diff changeset
    77
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    78
 *       <!-- Value -->
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    79
 *       <!-- Byte -->
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    80
 *       <th scope="col" style="width:3em"> 7 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    81
 *       <th scope="col" style="width:3em"> 6 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    82
 *       <th scope="col" style="width:3em"> 5 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    83
 *       <th scope="col" style="width:3em"> 4 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    84
 *       <th scope="col" style="width:3em"> 3 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    85
 *       <th scope="col" style="width:3em"> 2 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    86
 *       <th scope="col" style="width:3em"> 1 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    87
 *       <th scope="col" style="width:3em"> 0 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    88
 *     </thead>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    89
 *     <tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    91
 *       <th scope="row" style="text-align:left; font-weight:normal">
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    92
 *         {@code \u005Cu0001} to {@code \u005Cu007F} </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    93
 *       <th scope="row" style="font-weight:normal; text-align:center"> 1 </th>
44848
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
    94
 *       <td style="text-align:center">0
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    95
 *       <td colspan="7" style="text-align:right; padding-right:6em">bits 6-0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *     </tr>
19029
30c64a024c86 8020426: Fix doclint accessibility issues in java.io
juh
parents: 18786
diff changeset
    97
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    98
 *       <th scope="row" rowspan="2" style="text-align:left; font-weight:normal">
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
    99
 *           {@code \u005Cu0000},<br>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   100
 *           {@code \u005Cu0080} to {@code \u005Cu07FF} </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   101
 *       <th scope="row" style="font-weight:normal; text-align:center"> 1 </th>
44848
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   102
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   103
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   104
 *       <td style="text-align:center">0
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   105
 *       <td colspan="5" style="text-align:right; padding-right:6em">bits 10-6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *     </tr>
19029
30c64a024c86 8020426: Fix doclint accessibility issues in java.io
juh
parents: 18786
diff changeset
   107
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   108
 *       <!-- (value) -->
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   109
 *       <th scope="row" style="font-weight:normal; text-align:center"> 2 </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   110
 *       <td style="text-align:center">1
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   111
 *       <td style="text-align:center">0
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   112
 *       <td colspan="6" style="text-align:right; padding-right:6em">bits 5-0
19029
30c64a024c86 8020426: Fix doclint accessibility issues in java.io
juh
parents: 18786
diff changeset
   113
 *     </tr>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   115
 *       <th scope="row" rowspan="3" style="text-align:left; font-weight:normal">
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   116
 *         {@code \u005Cu0800} to {@code \u005CuFFFF} </th>
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   117
 *       <th scope="row" style="font-weight:normal; text-align:center"> 1 </th>
44848
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   118
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   119
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   120
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   121
 *       <td style="text-align:center">0
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   122
 *       <td colspan="4" style="text-align:right; padding-right:6em">bits 15-12
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   125
 *       <!-- (value) -->
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   126
 *       <th scope="row" style="font-weight:normal; text-align:center"> 2 </th>
44848
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   127
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   128
 *       <td style="text-align:center">0
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   129
 *       <td colspan="6" style="text-align:right; padding-right:6em">bits 11-6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *     </tr>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 *     <tr>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   132
 *       <!-- (value) -->
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   133
 *       <th scope="row" style="font-weight:normal; text-align:center"> 3 </th>
44848
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   134
 *       <td style="text-align:center">1
e946981dc37c 8179370: Replace use of <tt>, <center> and <font> tags in java.base
jjg
parents: 44844
diff changeset
   135
 *       <td style="text-align:center">0
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   136
 *       <td colspan="6" style="text-align:right; padding-right:6em">bits 5-0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 *     </tr>
45124
144479e89cdb 8179592: Update tables in java.base to be HTML 5-friendly.
jjg
parents: 44848
diff changeset
   138
 *     </tbody>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 *   </table>
46147
047bdc4d771d 8185994: Fix a11y and HTML issues in the java.base/java.io and java.base/java.nio packages
jjg
parents: 45124
diff changeset
   140
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 * The differences between this format and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 * standard UTF-8 format are the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
 * <ul>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   145
 * <li>The null byte {@code '\u005Cu0000'} is encoded in 2-byte format
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *     rather than 1-byte, so that the encoded strings never have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *     embedded nulls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 * <li>Only the 1-byte, 2-byte, and 3-byte formats are used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 * <li><a href="../lang/Character.html#unicode">Supplementary characters</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *     are represented in the form of surrogate pairs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 * @author  Frank Yellin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 * @see     java.io.DataInputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
 * @see     java.io.DataOutput
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 21624
diff changeset
   155
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
interface DataInput {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Reads some bytes from an input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * stream and stores them into the buffer
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   162
     * array {@code b}. The number of bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * read is equal
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   164
     * to the length of {@code b}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * This method blocks until one of the
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   167
     * following conditions occurs:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * <ul>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   169
     * <li>{@code b.length}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * bytes of input data are available, in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * case a normal return is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * <li>End of
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   174
     * file is detected, in which case an {@code EOFException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * <li>An I/O error occurs, in
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   178
     * which case an {@code IOException} other
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   179
     * than {@code EOFException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * <p>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   182
     * If {@code b} is {@code null},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   183
     * a {@code NullPointerException} is thrown.
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   184
     * If {@code b.length} is zero, then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * no bytes are read. Otherwise, the first
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   186
     * byte read is stored into element {@code b[0]},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   187
     * the next one into {@code b[1]}, and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * so on.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * If an exception is thrown from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * this method, then it may be that some but
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   191
     * not all bytes of {@code b} have been
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * updated with data from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
37591
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   194
     * @param   b   the buffer into which the data is read.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   195
     * @throws  NullPointerException if {@code b} is {@code null}.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   196
     * @throws  EOFException  if this stream reaches the end before reading
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   197
     *          all the bytes.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   198
     * @throws  IOException   if an I/O error occurs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    void readFully(byte b[]) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   204
     * Reads {@code len}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * bytes from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * an input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * blocks until one of the following conditions
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   210
     * occurs:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * <ul>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   212
     * <li>{@code len} bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * of input data are available, in which case
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * a normal return is made.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <li>End of file
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   217
     * is detected, in which case an {@code EOFException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * <li>An I/O error occurs, in
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   221
     * which case an {@code IOException} other
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   222
     * than {@code EOFException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * <p>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   225
     * If {@code b} is {@code null},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   226
     * a {@code NullPointerException} is thrown.
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   227
     * If {@code off} is negative, or {@code len}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   228
     * is negative, or {@code off+len} is
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   229
     * greater than the length of the array {@code b},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   230
     * then an {@code IndexOutOfBoundsException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * is thrown.
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   232
     * If {@code len} is zero,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * then no bytes are read. Otherwise, the first
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   234
     * byte read is stored into element {@code b[off]},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   235
     * the next one into {@code b[off+1]},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * and so on. The number of bytes read is,
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   237
     * at most, equal to {@code len}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
37591
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   239
     * @param   b    the buffer into which the data is read.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   240
     * @param   off  an int specifying the offset in the data array {@code b}.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   241
     * @param   len  an int specifying the number of bytes to read.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   242
     * @throws  NullPointerException if {@code b} is {@code null}.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   243
     * @throws  IndexOutOfBoundsException if {@code off} is negative,
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   244
     *          {@code len} is negative, or {@code len} is greater than
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   245
     *          {@code b.length - off}.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   246
     * @throws  EOFException  if this stream reaches the end before reading
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   247
     *          all the bytes.
b71bda3ce058 8154183: (spec) Spec of read(byte[],int,int) and readFully(byte[],int,int) is confusing/incomplete
bpb
parents: 25859
diff changeset
   248
     * @throws  IOException   if an I/O error occurs.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    void readFully(byte b[], int off, int len) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * Makes an attempt to skip over
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   254
     * {@code n} bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * of data from the input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * stream, discarding the skipped bytes. However,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * it may skip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * over some smaller number of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * bytes, possibly zero. This may result from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * any of a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * number of conditions; reaching
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   262
     * end of file before {@code n} bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * have been skipped is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * only one possibility.
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   265
     * This method never throws an {@code EOFException}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * The actual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * number of bytes skipped is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * @param      n   the number of bytes to be skipped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @return     the number of bytes actually skipped.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    int skipBytes(int n) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Reads one input byte and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   277
     * {@code true} if that byte is nonzero,
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   278
     * {@code false} if that byte is zero.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * This method is suitable for reading
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   280
     * the byte written by the {@code writeBoolean}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   281
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   283
     * @return     the {@code boolean} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    boolean readBoolean() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Reads and returns one input byte.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * The byte is treated as a signed value in
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   293
     * the range {@code -128} through {@code 127},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * inclusive.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * This method is suitable for
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   296
     * reading the byte written by the {@code writeByte}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   297
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @return     the 8-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     *               all the bytes.
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
    byte readByte() 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, zero-extends
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   308
     * it to type {@code int}, and returns
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * the result, which is therefore in the range
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   310
     * {@code 0}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   311
     * through {@code 255}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * This method is suitable for reading
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   313
     * the byte written by the {@code writeByte}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   314
     * method of interface {@code DataOutput}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   315
     * if the argument to {@code writeByte}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * was intended to be a value in the range
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   317
     * {@code 0} through {@code 255}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @return     the unsigned 8-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    int readUnsignedByte() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * Reads two input bytes and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   328
     * a {@code short} value. Let {@code a}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   329
     * be the first byte read and {@code b}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * be the second byte. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * is:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   333
     * <pre>{@code (short)((a << 8) | (b & 0xff))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   334
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * is suitable for reading the bytes written
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   337
     * by the {@code writeShort} method of
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   338
     * interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @return     the 16-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    short readShort() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * Reads two input bytes and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   349
     * an {@code int} value in the range {@code 0}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   350
     * through {@code 65535}. Let {@code a}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * be the first byte read and
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   352
     * {@code b}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * be the second byte. The value returned is:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   354
     * <pre>{@code (((a & 0xff) << 8) | (b & 0xff))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   355
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * This method is suitable for reading the bytes
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   357
     * written by the {@code writeShort} method
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   358
     * of interface {@code DataOutput}  if
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   359
     * the argument to {@code writeShort}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * was intended to be a value in the range
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   361
     * {@code 0} through {@code 65535}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @return     the unsigned 16-bit value read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    int readUnsignedShort() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    /**
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   371
     * Reads two input bytes and returns a {@code char} value.
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   372
     * Let {@code a}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   373
     * be the first byte read and {@code b}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * be the second byte. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * returned is:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   376
     * <pre>{@code (char)((a << 8) | (b & 0xff))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   377
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * is suitable for reading bytes written by
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   380
     * the {@code writeChar} method of interface
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   381
     * {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   383
     * @return     the {@code char} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    char readChar() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * Reads four input bytes and returns an
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   392
     * {@code int} value. Let {@code a-d}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * be the first through fourth bytes read. The value returned is:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   394
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   395
     * (((a & 0xff) << 24) | ((b & 0xff) << 16) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   396
     *  ((c & 0xff) <<  8) | (d & 0xff))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   397
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * This method is suitable
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   399
     * for reading bytes written by the {@code writeInt}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   400
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   402
     * @return     the {@code int} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
    int readInt() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * Reads eight input bytes and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   411
     * a {@code long} value. Let {@code a-h}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * be the first through eighth bytes read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * The value returned is:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   414
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   415
     * (((long)(a & 0xff) << 56) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   416
     *  ((long)(b & 0xff) << 48) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   417
     *  ((long)(c & 0xff) << 40) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   418
     *  ((long)(d & 0xff) << 32) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   419
     *  ((long)(e & 0xff) << 24) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   420
     *  ((long)(f & 0xff) << 16) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   421
     *  ((long)(g & 0xff) <<  8) |
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   422
     *  ((long)(h & 0xff)))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   423
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * This method is suitable
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   426
     * for reading bytes written by the {@code writeLong}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   427
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   429
     * @return     the {@code long} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    long readLong() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Reads four input bytes and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   438
     * a {@code float} value. It does this
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   439
     * by first constructing an {@code int}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * value in exactly the manner
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   441
     * of the {@code readInt}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   442
     * method, then converting this {@code int}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   443
     * value to a {@code float} in
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   444
     * exactly the manner of the method {@code Float.intBitsToFloat}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * This method is suitable for reading
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   446
     * bytes written by the {@code writeFloat}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   447
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   449
     * @return     the {@code float} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
    float readFloat() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * Reads eight input bytes and returns
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   458
     * a {@code double} value. It does this
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   459
     * by first constructing a {@code long}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * value in exactly the manner
21624
2648e47a6654 8024458: DataInput.readDouble refers to "readlong" instead of "readLong"
rriggs
parents: 21334
diff changeset
   461
     * of the {@code readLong}
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   462
     * method, then converting this {@code long}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   463
     * value to a {@code double} in exactly
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   464
     * the manner of the method {@code Double.longBitsToDouble}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * This method is suitable for reading
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   466
     * bytes written by the {@code writeDouble}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   467
     * method of interface {@code DataOutput}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   469
     * @return     the {@code double} value read.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @exception  EOFException  if this stream reaches the end before reading
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *               all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @exception  IOException   if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    double readDouble() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * Reads the next line of text from the input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * It reads successive bytes, converting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * each byte separately into a character,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * until it encounters a line terminator or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * end of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * file; the characters read are then
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   483
     * returned as a {@code String}. Note
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * that because this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * method processes bytes,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * it does not support input of the full Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * character set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * If end of file is encountered
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   490
     * before even one byte can be read, then {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * is returned. Otherwise, each byte that is
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   492
     * read is converted to type {@code char}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   493
     * by zero-extension. If the character {@code '\n'}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * is encountered, it is discarded and reading
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   495
     * ceases. If the character {@code '\r'}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * is encountered, it is discarded and, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * the following byte converts &#32;to the
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   498
     * character {@code '\n'}, then that is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * discarded also; reading then ceases. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * end of file is encountered before either
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   501
     * of the characters {@code '\n'} and
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   502
     * {@code '\r'} is encountered, reading
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   503
     * ceases. Once reading has ceased, a {@code String}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * is returned that contains all the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * read and not discarded, taken in order.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Note that every character in this string
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   507
     * will have a value less than {@code \u005Cu0100},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   508
     * that is, {@code (char)256}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @return the next line of text from the input stream,
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   511
     *         or {@code null} if the end of file is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     *         encountered before a byte can be read.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * @exception  IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    String readLine() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * Reads in a string that has been encoded using a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * <a href="#modified-utf-8">modified UTF-8</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * format.
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   521
     * The general contract of {@code readUTF}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * is that it reads a representation of a Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * character string encoded in modified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * UTF-8 format; this string of characters
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   525
     * is then returned as a {@code String}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * First, two bytes are read and used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * construct an unsigned 16-bit integer in
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   529
     * exactly the manner of the {@code readUnsignedShort}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * method . This integer value is called the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * <i>UTF length</i> and specifies the number
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * of additional bytes to be read. These bytes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * are then converted to characters by considering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * them in groups. The length of each group
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * is computed from the value of the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * byte of the group. The byte following a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * group, if any, is the first byte of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * next group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * If the first byte of a group
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   541
     * matches the bit pattern {@code 0xxxxxxx}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   542
     * (where {@code x} means "may be {@code 0}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   543
     * or {@code 1}"), then the group consists
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * of just that byte. The byte is zero-extended
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * to form a character.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * If the first byte
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   548
     * of a group matches the bit pattern {@code 110xxxxx},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   549
     * then the group consists of that byte {@code a}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   550
     * and a second byte {@code b}. If there
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   551
     * is no byte {@code b} (because byte
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   552
     * {@code a} was the last of the bytes
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   553
     * to be read), or if byte {@code b} does
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   554
     * not match the bit pattern {@code 10xxxxxx},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   555
     * then a {@code UTFDataFormatException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     * is thrown. Otherwise, the group is converted
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   557
     * to the character:
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   558
     * <pre>{@code (char)(((a & 0x1F) << 6) | (b & 0x3F))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   559
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * If the first byte of a group
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   561
     * matches the bit pattern {@code 1110xxxx},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   562
     * then the group consists of that byte {@code a}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   563
     * and two more bytes {@code b} and {@code c}.
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   564
     * If there is no byte {@code c} (because
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   565
     * byte {@code a} was one of the last
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * two of the bytes to be read), or either
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   567
     * byte {@code b} or byte {@code c}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   568
     * does not match the bit pattern {@code 10xxxxxx},
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   569
     * then a {@code UTFDataFormatException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * is thrown. Otherwise, the group is converted
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   571
     * to the character:
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   572
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   573
     * (char)(((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 19029
diff changeset
   574
     * }</pre>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * If the first byte of a group matches the
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   576
     * pattern {@code 1111xxxx} or the pattern
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   577
     * {@code 10xxxxxx}, then a {@code UTFDataFormatException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * If end of file is encountered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * at any time during this entire process,
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   582
     * then an {@code EOFException} is thrown.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * After every group has been converted to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * a character by this process, the characters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * are gathered, in the same order in which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * their corresponding groups were read from
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   588
     * the input stream, to form a {@code String},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * which is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * <p>
11676
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   591
     * The {@code writeUTF}
7e75ec031b97 7132338: Use @code friendly idiom for '\' in javadoc
darcy
parents: 5506
diff changeset
   592
     * method of interface {@code DataOutput}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * may be used to write data that is suitable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * for reading by this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * @return     a Unicode string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * @exception  EOFException            if this stream reaches the end
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *               before reading all the bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @exception  IOException             if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @exception  UTFDataFormatException  if the bytes do not represent a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *               valid modified UTF-8 encoding of a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    String readUTF() throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
}