src/java.base/share/classes/java/io/DataOutput.java
author jlahoda
Mon, 30 Apr 2018 15:03:08 +0200
changeset 49924 84d0fe3cefd4
parent 47216 71c04702a3d5
child 58288 48e480e56aad
permissions -rw-r--r--
8202105: Console echo is disabled when exiting jshell Summary: Preserving original terminal echo state when Console.readPassword finishes. Reviewed-by: sherman, martin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 21334
diff changeset
     2
 * Copyright (c) 1995, 2013, 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>DataOutput</code> interface provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * for converting data from any of the Java
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * primitive types to a series of bytes and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * writing these bytes to a binary stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * There is  also a facility for converting
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * a <code>String</code> into
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * <a href="DataInput.html#modified-utf-8">modified UTF-8</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * format and writing the resulting series
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * of bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * For all the methods in this interface that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * write bytes, it is generally true that if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * a byte cannot be written for any reason,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * an <code>IOException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * @author  Frank Yellin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see     java.io.DataInput
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see     java.io.DataOutputStream
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
    47
 * @since   1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
interface DataOutput {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * Writes to the output stream the eight
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * low-order bits of the argument <code>b</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * The 24 high-order  bits of <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * are ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @param      b   the byte to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    void write(int b) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Writes to the output stream all the bytes in array <code>b</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * If <code>b</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     * a <code>NullPointerException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     * If <code>b.length</code> is zero, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * no bytes are written. Otherwise, the byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * <code>b[0]</code> is written first, then
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * <code>b[1]</code>, and so on; the last byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * written is <code>b[b.length-1]</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * @param      b   the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    void write(byte b[]) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Writes <code>len</code> bytes from array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * <code>b</code>, in order,  to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * the output stream.  If <code>b</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * is <code>null</code>, a <code>NullPointerException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * is thrown.  If <code>off</code> is negative,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * or <code>len</code> is negative, or <code>off+len</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * is greater than the length of the array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * <code>b</code>, then an <code>IndexOutOfBoundsException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * is thrown.  If <code>len</code> is zero,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * then no bytes are written. Otherwise, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * byte <code>b[off]</code> is written first,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * then <code>b[off+1]</code>, and so on; the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * last byte written is <code>b[off+len-1]</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @param      b     the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @param      off   the start offset in the data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @param      len   the number of bytes to write.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    void write(byte b[], int off, int len) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Writes a <code>boolean</code> value to this output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * If the argument <code>v</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * is <code>true</code>, the value <code>(byte)1</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * is written; if <code>v</code> is <code>false</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * the  value <code>(byte)0</code> is written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * The byte written by this method may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * be read by the <code>readBoolean</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * method of interface <code>DataInput</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * which will then return a <code>boolean</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * equal to <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param      v   the boolean to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    void writeBoolean(boolean v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * Writes to the output stream the eight low-
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * order bits of the argument <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * The 24 high-order bits of <code>v</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * are ignored. (This means  that <code>writeByte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * does exactly the same thing as <code>write</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * for an integer argument.) The byte written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * by this method may be read by the <code>readByte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * method of interface <code>DataInput</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * which will then return a <code>byte</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * equal to <code>(byte)v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @param      v   the byte value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    void writeByte(int v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Writes two bytes to the output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * stream to represent the value of the argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * The byte values to be written, in the  order
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   137
     * shown, are:
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   138
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   139
     * (byte)(0xff & (v >> 8))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   140
     * (byte)(0xff & v)
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   141
     * }</pre> <p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * The bytes written by this method may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * read by the <code>readShort</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * of interface <code>DataInput</code> , which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * will then return a <code>short</code> equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * to <code>(short)v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param      v   the <code>short</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    void writeShort(int v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Writes a <code>char</code> value, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * is comprised of two bytes, to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * The byte values to be written, in the  order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * shown, are:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   159
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   160
     * (byte)(0xff & (v >> 8))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   161
     * (byte)(0xff & v)
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   162
     * }</pre><p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * The bytes written by this method may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * read by the <code>readChar</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * of interface <code>DataInput</code> , which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * will then return a <code>char</code> equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * to <code>(char)v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @param      v   the <code>char</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    void writeChar(int v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Writes an <code>int</code> value, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * comprised of four bytes, to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * The byte values to be written, in the  order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * shown, are:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   179
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   180
     * (byte)(0xff & (v >> 24))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   181
     * (byte)(0xff & (v >> 16))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   182
     * (byte)(0xff & (v >>  8))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   183
     * (byte)(0xff & v)
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   184
     * }</pre><p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * The bytes written by this method may be read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * by the <code>readInt</code> method of interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * <code>DataInput</code> , which will then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * return an <code>int</code> equal to <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param      v   the <code>int</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    void writeInt(int v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Writes a <code>long</code> value, which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * comprised of eight bytes, to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * The byte values to be written, in the  order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * shown, are:
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   200
     * <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   201
     * (byte)(0xff & (v >> 56))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   202
     * (byte)(0xff & (v >> 48))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   203
     * (byte)(0xff & (v >> 40))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   204
     * (byte)(0xff & (v >> 32))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   205
     * (byte)(0xff & (v >> 24))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   206
     * (byte)(0xff & (v >> 16))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   207
     * (byte)(0xff & (v >>  8))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   208
     * (byte)(0xff & v)
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   209
     * }</pre><p>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * The bytes written by this method may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * read by the <code>readLong</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * of interface <code>DataInput</code> , which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * will then return a <code>long</code> equal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * to <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @param      v   the <code>long</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    void writeLong(long v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Writes a <code>float</code> value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * which is comprised of four bytes, to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * It does this as if it first converts this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * <code>float</code> value to an <code>int</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * in exactly the manner of the <code>Float.floatToIntBits</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * method  and then writes the <code>int</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * value in exactly the manner of the  <code>writeInt</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * method.  The bytes written by this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * may be read by the <code>readFloat</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * method of interface <code>DataInput</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * which will then return a <code>float</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * equal to <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @param      v   the <code>float</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    void writeFloat(float v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * Writes a <code>double</code> value,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * which is comprised of eight bytes, to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * It does this as if it first converts this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * <code>double</code> value to a <code>long</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * in exactly the manner of the <code>Double.doubleToLongBits</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * method  and then writes the <code>long</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * value in exactly the manner of the  <code>writeLong</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * method. The bytes written by this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * may be read by the <code>readDouble</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * method of interface <code>DataInput</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * which will then return a <code>double</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * equal to <code>v</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @param      v   the <code>double</code> value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    void writeDouble(double v) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Writes a string to the output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * For every character in the string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * <code>s</code>,  taken in order, one byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * is written to the output stream.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * <code>s</code> is <code>null</code>, a <code>NullPointerException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * is thrown.<p>  If <code>s.length</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * is zero, then no bytes are written. Otherwise,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * the character <code>s[0]</code> is written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * first, then <code>s[1]</code>, and so on;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * the last character written is <code>s[s.length-1]</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * For each character, one byte is written,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * the low-order byte, in exactly the manner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * of the <code>writeByte</code> method . The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * high-order eight bits of each character
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * in the string are ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * @param      s   the string of bytes to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    void writeBytes(String s) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Writes every character in the string <code>s</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * to the output stream, in order,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * two bytes per character. If <code>s</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * is <code>null</code>, a <code>NullPointerException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * is thrown.  If <code>s.length</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * is zero, then no characters are written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Otherwise, the character <code>s[0]</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * is written first, then <code>s[1]</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * and so on; the last character written is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * <code>s[s.length-1]</code>. For each character,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * two bytes are actually written, high-order
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * byte first, in exactly the manner of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * <code>writeChar</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * @param      s   the string value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    void writeChars(String s) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * Writes two bytes of length information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * to the output stream, followed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * <a href="DataInput.html#modified-utf-8">modified UTF-8</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * representation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * of  every character in the string <code>s</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * If <code>s</code> is <code>null</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * a <code>NullPointerException</code> is thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * Each character in the string <code>s</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * is converted to a group of one, two, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * three bytes, depending on the value of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * character.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * If a character <code>c</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * is in the range <code>&#92;u0001</code> through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * <code>&#92;u007f</code>, it is represented
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   317
     * by one byte:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * <pre>(byte)c </pre>  <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * If a character <code>c</code> is <code>&#92;u0000</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * or is in the range <code>&#92;u0080</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * through <code>&#92;u07ff</code>, then it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * represented by two bytes, to be written
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   323
     * in the order shown: <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   324
     * (byte)(0xc0 | (0x1f & (c >> 6)))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   325
     * (byte)(0x80 | (0x3f & c))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   326
     * }</pre> <p> If a character
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * <code>c</code> is in the range <code>&#92;u0800</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * through <code>uffff</code>, then it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * represented by three bytes, to be written
21334
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   330
     * in the order shown: <pre>{@code
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   331
     * (byte)(0xe0 | (0x0f & (c >> 12)))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   332
     * (byte)(0x80 | (0x3f & (c >>  6)))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   333
     * (byte)(0x80 | (0x3f & c))
c60dfce46a77 8026982: javadoc errors in core libs
rriggs
parents: 5506
diff changeset
   334
     * }</pre>  <p> First,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * the total number of bytes needed to represent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * all the characters of <code>s</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * calculated. If this number is larger than
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * <code>65535</code>, then a <code>UTFDataFormatException</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * is thrown. Otherwise, this length is written
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * to the output stream in exactly the manner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * of the <code>writeShort</code> method;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * after this, the one-, two-, or three-byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * representation of each character in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * string <code>s</code> is written.<p>  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * bytes written by this method may be read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * by the <code>readUTF</code> method of interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * <code>DataInput</code> , which will then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * return a <code>String</code> equal to <code>s</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @param      s   the string value to be written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @throws     IOException  if an I/O error occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    void writeUTF(String s) throws IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
}