2362N/A * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * A data output stream lets an application write primitive Java data 0N/A * types to an output stream in a portable way. An application can 0N/A * then use a data input stream to read the data back in. 0N/A * @author unascribed 0N/A * @see java.io.DataInputStream 0N/A * The number of bytes written to the data output stream so far. 0N/A * If this counter overflows, it will be wrapped to Integer.MAX_VALUE. 0N/A * bytearr is initialized on demand by writeUTF 0N/A * Creates a new data output stream to write data to the specified 0N/A * underlying output stream. The counter <code>written</code> is 0N/A * @param out the underlying output stream, to be saved for later 0N/A * @see java.io.FilterOutputStream#out 0N/A * Increases the written counter by the specified value 0N/A * until it reaches Integer.MAX_VALUE. 0N/A * Writes the specified byte (the low eight bits of the argument 0N/A * <code>b</code>) to the underlying output stream. If no exception 0N/A * is thrown, the counter <code>written</code> is incremented by 0N/A * Implements the <code>write</code> method of <code>OutputStream</code>. 0N/A * @param b the <code>byte</code> to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes <code>len</code> bytes from the specified byte array 0N/A * starting at offset <code>off</code> to the underlying output stream. 0N/A * If no exception is thrown, the counter <code>written</code> is 0N/A * incremented by <code>len</code>. 0N/A * @param b the data. 0N/A * @param off the start offset in the data. 0N/A * @param len the number of bytes to write. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Flushes this data output stream. This forces any buffered output 0N/A * bytes to be written out to the stream. 0N/A * The <code>flush</code> method of <code>DataOutputStream</code> 0N/A * calls the <code>flush</code> method of its underlying output stream. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * @see java.io.OutputStream#flush() 0N/A * Writes a <code>boolean</code> to the underlying output stream as 0N/A * a 1-byte value. The value <code>true</code> is written out as the 0N/A * value <code>(byte)1</code>; the value <code>false</code> is 0N/A * written out as the value <code>(byte)0</code>. If no exception is 0N/A * thrown, the counter <code>written</code> is incremented by 0N/A * @param v a <code>boolean</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes out a <code>byte</code> to the underlying output stream as 0N/A * a 1-byte value. If no exception is thrown, the counter 0N/A * <code>written</code> is incremented by <code>1</code>. 0N/A * @param v a <code>byte</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes a <code>short</code> to the underlying output stream as two 0N/A * bytes, high byte first. If no exception is thrown, the counter 0N/A * <code>written</code> is incremented by <code>2</code>. 0N/A * @param v a <code>short</code> to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes a <code>char</code> to the underlying output stream as a 0N/A * 2-byte value, high byte first. If no exception is thrown, the 0N/A * counter <code>written</code> is incremented by <code>2</code>. 0N/A * @param v a <code>char</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes an <code>int</code> to the underlying output stream as four 0N/A * bytes, high byte first. If no exception is thrown, the counter 0N/A * <code>written</code> is incremented by <code>4</code>. 0N/A * @param v an <code>int</code> to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Writes a <code>long</code> to the underlying output stream as eight 0N/A * bytes, high byte first. In no exception is thrown, the counter 0N/A * <code>written</code> is incremented by <code>8</code>. 0N/A * @param v a <code>long</code> to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * Converts the float argument to an <code>int</code> using the 0N/A * <code>floatToIntBits</code> method in class <code>Float</code>, 0N/A * and then writes that <code>int</code> value to the underlying 0N/A * output stream as a 4-byte quantity, high byte first. If no 0N/A * exception is thrown, the counter <code>written</code> is 0N/A * incremented by <code>4</code>. 0N/A * @param v a <code>float</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * @see java.lang.Float#floatToIntBits(float) 0N/A * Converts the double argument to a <code>long</code> using the 0N/A * <code>doubleToLongBits</code> method in class <code>Double</code>, 0N/A * and then writes that <code>long</code> value to the underlying 0N/A * output stream as an 8-byte quantity, high byte first. If no 0N/A * exception is thrown, the counter <code>written</code> is 0N/A * incremented by <code>8</code>. 0N/A * @param v a <code>double</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A * @see java.lang.Double#doubleToLongBits(double) 0N/A * Writes out the string to the underlying output stream as a 0N/A * sequence of bytes. Each character in the string is written out, in 0N/A * sequence, by discarding its high eight bits. If no exception is 0N/A * thrown, the counter <code>written</code> is incremented by the 0N/A * length of <code>s</code>. 0N/A * @param s a string of bytes to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.FilterOutputStream#out 0N/A for (
int i =
0 ; i <
len ; i++) {
0N/A * Writes a string to the underlying output stream as a sequence of 0N/A * characters. Each character is written to the data output stream as 0N/A * if by the <code>writeChar</code> method. If no exception is 0N/A * thrown, the counter <code>written</code> is incremented by twice 0N/A * the length of <code>s</code>. 0N/A * @param s a <code>String</code> value to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * @see java.io.DataOutputStream#writeChar(int) 0N/A * @see java.io.FilterOutputStream#out 0N/A for (
int i =
0 ; i <
len ; i++) {
0N/A * Writes a string to the underlying output stream using 0N/A * encoding in a machine-independent manner. 0N/A * First, two bytes are written to the output stream as if by the 0N/A * <code>writeShort</code> method giving the number of bytes to 0N/A * follow. This value is the number of bytes actually written out, 0N/A * not the length of the string. Following the length, each character 0N/A * of the string is output, in sequence, using the modified UTF-8 encoding 0N/A * for the character. If no exception is thrown, the counter 0N/A * <code>written</code> is incremented by the total number of 0N/A * bytes written to the output stream. This will be at least two 0N/A * plus the length of <code>str</code>, and at most two plus 0N/A * thrice the length of <code>str</code>. 0N/A * @param str a string to be written. 0N/A * @exception IOException if an I/O error occurs. 0N/A * Writes a string to the specified DataOutput using 0N/A * encoding in a machine-independent manner. 0N/A * First, two bytes are written to out as if by the <code>writeShort</code> 0N/A * method giving the number of bytes to follow. This value is the number of 0N/A * bytes actually written out, not the length of the string. Following the 0N/A * length, each character of the string is output, in sequence, using the 0N/A * modified UTF-8 encoding for the character. If no exception is thrown, the 0N/A * counter <code>written</code> is incremented by the total number of 0N/A * bytes written to the output stream. This will be at least two 0N/A * plus the length of <code>str</code>, and at most two plus 0N/A * thrice the length of <code>str</code>. 0N/A * @param str a string to be written. 0N/A * @param out destination to write to 0N/A * @return The number of bytes written out. 0N/A * @exception IOException if an I/O error occurs. 0N/A /* use charAt instead of copying String to char array */ 0N/A if ((c >=
0x0001) && (c <=
0x007F)) {
0N/A }
else if (c >
0x07FF) {
0N/A "encoded string too long: " +
utflen +
" bytes");
0N/A if (!((c >=
0x0001) && (c <=
0x007F)))
break;
0N/A if ((c >=
0x0001) && (c <=
0x007F)) {
0N/A }
else if (c >
0x07FF) {
0N/A * Returns the current value of the counter <code>written</code>, 0N/A * the number of bytes written to this data output stream so far. 0N/A * If the counter overflows, it will be wrapped to Integer.MAX_VALUE. 0N/A * @return the value of the <code>written</code> field. 0N/A * @see java.io.DataOutputStream#written