0N/A/*
2362N/A * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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 *
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 *
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.
0N/A *
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
2362N/A * questions.
0N/A */
0N/A
0N/Apackage java.io;
0N/A
0N/A/**
0N/A * A data input stream lets an application read primitive Java data
0N/A * types from an underlying input stream in a machine-independent
0N/A * way. An application uses a data output stream to write data that
0N/A * can later be read by a data input stream.
0N/A * <p>
0N/A * DataInputStream is not necessarily safe for multithreaded access.
0N/A * Thread safety is optional and is the responsibility of users of
0N/A * methods in this class.
0N/A *
0N/A * @author Arthur van Hoff
0N/A * @see java.io.DataOutputStream
0N/A * @since JDK1.0
0N/A */
0N/Apublic
0N/Aclass DataInputStream extends FilterInputStream implements DataInput {
0N/A
0N/A /**
0N/A * Creates a DataInputStream that uses the specified
0N/A * underlying InputStream.
0N/A *
0N/A * @param in the specified input stream
0N/A */
0N/A public DataInputStream(InputStream in) {
0N/A super(in);
0N/A }
0N/A
0N/A /**
0N/A * working arrays initialized on demand by readUTF
0N/A */
0N/A private byte bytearr[] = new byte[80];
0N/A private char chararr[] = new char[80];
0N/A
0N/A /**
0N/A * Reads some number of bytes from the contained input stream and
0N/A * stores them into the buffer array <code>b</code>. The number of
0N/A * bytes actually read is returned as an integer. This method blocks
0N/A * until input data is available, end of file is detected, or an
0N/A * exception is thrown.
0N/A *
0N/A * <p>If <code>b</code> is null, a <code>NullPointerException</code> is
0N/A * thrown. If the length of <code>b</code> is zero, then no bytes are
0N/A * read and <code>0</code> is returned; otherwise, there is an attempt
0N/A * to read at least one byte. If no byte is available because the
0N/A * stream is at end of file, the value <code>-1</code> is returned;
0N/A * otherwise, at least one byte is read and stored into <code>b</code>.
0N/A *
0N/A * <p>The first byte read is stored into element <code>b[0]</code>, the
0N/A * next one into <code>b[1]</code>, and so on. The number of bytes read
0N/A * is, at most, equal to the length of <code>b</code>. Let <code>k</code>
0N/A * be the number of bytes actually read; these bytes will be stored in
0N/A * elements <code>b[0]</code> through <code>b[k-1]</code>, leaving
0N/A * elements <code>b[k]</code> through <code>b[b.length-1]</code>
0N/A * unaffected.
0N/A *
0N/A * <p>The <code>read(b)</code> method has the same effect as:
0N/A * <blockquote><pre>
0N/A * read(b, 0, b.length)
0N/A * </pre></blockquote>
0N/A *
0N/A * @param b the buffer into which the data is read.
0N/A * @return the total number of bytes read into the buffer, or
0N/A * <code>-1</code> if there is no more data because the end
0N/A * of the stream has been reached.
0N/A * @exception IOException if the first byte cannot be read for any reason
0N/A * other than end of file, the stream has been closed and the underlying
0N/A * input stream does not support reading after close, or another I/O
0N/A * error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A * @see java.io.InputStream#read(byte[], int, int)
0N/A */
0N/A public final int read(byte b[]) throws IOException {
0N/A return in.read(b, 0, b.length);
0N/A }
0N/A
0N/A /**
0N/A * Reads up to <code>len</code> bytes of data from the contained
0N/A * input stream into an array of bytes. An attempt is made to read
0N/A * as many as <code>len</code> bytes, but a smaller number may be read,
0N/A * possibly zero. The number of bytes actually read is returned as an
0N/A * integer.
0N/A *
0N/A * <p> This method blocks until input data is available, end of file is
0N/A * detected, or an exception is thrown.
0N/A *
0N/A * <p> If <code>len</code> is zero, then no bytes are read and
0N/A * <code>0</code> is returned; otherwise, there is an attempt to read at
0N/A * least one byte. If no byte is available because the stream is at end of
0N/A * file, the value <code>-1</code> is returned; otherwise, at least one
0N/A * byte is read and stored into <code>b</code>.
0N/A *
0N/A * <p> The first byte read is stored into element <code>b[off]</code>, the
0N/A * next one into <code>b[off+1]</code>, and so on. The number of bytes read
0N/A * is, at most, equal to <code>len</code>. Let <i>k</i> be the number of
0N/A * bytes actually read; these bytes will be stored in elements
0N/A * <code>b[off]</code> through <code>b[off+</code><i>k</i><code>-1]</code>,
0N/A * leaving elements <code>b[off+</code><i>k</i><code>]</code> through
0N/A * <code>b[off+len-1]</code> unaffected.
0N/A *
0N/A * <p> In every case, elements <code>b[0]</code> through
0N/A * <code>b[off]</code> and elements <code>b[off+len]</code> through
0N/A * <code>b[b.length-1]</code> are unaffected.
0N/A *
0N/A * @param b the buffer into which the data is read.
0N/A * @param off the start offset in the destination array <code>b</code>
0N/A * @param len the maximum number of bytes read.
0N/A * @return the total number of bytes read into the buffer, or
0N/A * <code>-1</code> if there is no more data because the end
0N/A * of the stream has been reached.
0N/A * @exception NullPointerException If <code>b</code> is <code>null</code>.
0N/A * @exception IndexOutOfBoundsException If <code>off</code> is negative,
0N/A * <code>len</code> is negative, or <code>len</code> is greater than
0N/A * <code>b.length - off</code>
0N/A * @exception IOException if the first byte cannot be read for any reason
0N/A * other than end of file, the stream has been closed and the underlying
0N/A * input stream does not support reading after close, or another I/O
0N/A * error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A * @see java.io.InputStream#read(byte[], int, int)
0N/A */
0N/A public final int read(byte b[], int off, int len) throws IOException {
0N/A return in.read(b, off, len);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readFully</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @param b the buffer into which the data is read.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final void readFully(byte b[]) throws IOException {
0N/A readFully(b, 0, b.length);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readFully</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @param b the buffer into which the data is read.
0N/A * @param off the start offset of the data.
0N/A * @param len the number of bytes to read.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final void readFully(byte b[], int off, int len) throws IOException {
0N/A if (len < 0)
0N/A throw new IndexOutOfBoundsException();
0N/A int n = 0;
0N/A while (n < len) {
0N/A int count = in.read(b, off + n, len - n);
0N/A if (count < 0)
0N/A throw new EOFException();
0N/A n += count;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>skipBytes</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @param n the number of bytes to be skipped.
0N/A * @return the actual number of bytes skipped.
0N/A * @exception IOException if the contained input stream does not support
0N/A * seek, or the stream has been closed and
0N/A * the contained input stream does not support
0N/A * reading after close, or another I/O error occurs.
0N/A */
0N/A public final int skipBytes(int n) throws IOException {
0N/A int total = 0;
0N/A int cur = 0;
0N/A
0N/A while ((total<n) && ((cur = (int) in.skip(n-total)) > 0)) {
0N/A total += cur;
0N/A }
0N/A
0N/A return total;
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readBoolean</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the <code>boolean</code> value read.
0N/A * @exception EOFException if this input stream has reached the end.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final boolean readBoolean() throws IOException {
0N/A int ch = in.read();
0N/A if (ch < 0)
0N/A throw new EOFException();
0N/A return (ch != 0);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readByte</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next byte of this input stream as a signed 8-bit
0N/A * <code>byte</code>.
0N/A * @exception EOFException if this input stream has reached the end.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final byte readByte() throws IOException {
0N/A int ch = in.read();
0N/A if (ch < 0)
0N/A throw new EOFException();
0N/A return (byte)(ch);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readUnsignedByte</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next byte of this input stream, interpreted as an
0N/A * unsigned 8-bit number.
0N/A * @exception EOFException if this input stream has reached the end.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final int readUnsignedByte() throws IOException {
0N/A int ch = in.read();
0N/A if (ch < 0)
0N/A throw new EOFException();
0N/A return ch;
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readShort</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next two bytes of this input stream, interpreted as a
0N/A * signed 16-bit number.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading two bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final short readShort() throws IOException {
0N/A int ch1 = in.read();
0N/A int ch2 = in.read();
0N/A if ((ch1 | ch2) < 0)
0N/A throw new EOFException();
0N/A return (short)((ch1 << 8) + (ch2 << 0));
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readUnsignedShort</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next two bytes of this input stream, interpreted as an
0N/A * unsigned 16-bit integer.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading two bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final int readUnsignedShort() throws IOException {
0N/A int ch1 = in.read();
0N/A int ch2 = in.read();
0N/A if ((ch1 | ch2) < 0)
0N/A throw new EOFException();
0N/A return (ch1 << 8) + (ch2 << 0);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readChar</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next two bytes of this input stream, interpreted as a
0N/A * <code>char</code>.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading two bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final char readChar() throws IOException {
0N/A int ch1 = in.read();
0N/A int ch2 = in.read();
0N/A if ((ch1 | ch2) < 0)
0N/A throw new EOFException();
0N/A return (char)((ch1 << 8) + (ch2 << 0));
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readInt</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next four bytes of this input stream, interpreted as an
0N/A * <code>int</code>.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading four bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final int readInt() throws IOException {
0N/A int ch1 = in.read();
0N/A int ch2 = in.read();
0N/A int ch3 = in.read();
0N/A int ch4 = in.read();
0N/A if ((ch1 | ch2 | ch3 | ch4) < 0)
0N/A throw new EOFException();
0N/A return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
0N/A }
0N/A
0N/A private byte readBuffer[] = new byte[8];
0N/A
0N/A /**
0N/A * See the general contract of the <code>readLong</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next eight bytes of this input stream, interpreted as a
0N/A * <code>long</code>.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading eight bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A public final long readLong() throws IOException {
0N/A readFully(readBuffer, 0, 8);
0N/A return (((long)readBuffer[0] << 56) +
0N/A ((long)(readBuffer[1] & 255) << 48) +
0N/A ((long)(readBuffer[2] & 255) << 40) +
0N/A ((long)(readBuffer[3] & 255) << 32) +
0N/A ((long)(readBuffer[4] & 255) << 24) +
0N/A ((readBuffer[5] & 255) << 16) +
0N/A ((readBuffer[6] & 255) << 8) +
0N/A ((readBuffer[7] & 255) << 0));
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readFloat</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next four bytes of this input stream, interpreted as a
0N/A * <code>float</code>.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading four bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.DataInputStream#readInt()
0N/A * @see java.lang.Float#intBitsToFloat(int)
0N/A */
0N/A public final float readFloat() throws IOException {
0N/A return Float.intBitsToFloat(readInt());
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readDouble</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return the next eight bytes of this input stream, interpreted as a
0N/A * <code>double</code>.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading eight bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @see java.io.DataInputStream#readLong()
0N/A * @see java.lang.Double#longBitsToDouble(long)
0N/A */
0N/A public final double readDouble() throws IOException {
0N/A return Double.longBitsToDouble(readLong());
0N/A }
0N/A
0N/A private char lineBuffer[];
0N/A
0N/A /**
0N/A * See the general contract of the <code>readLine</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @deprecated This method does not properly convert bytes to characters.
0N/A * As of JDK&nbsp;1.1, the preferred way to read lines of text is via the
0N/A * <code>BufferedReader.readLine()</code> method. Programs that use the
0N/A * <code>DataInputStream</code> class to read lines can be converted to use
0N/A * the <code>BufferedReader</code> class by replacing code of the form:
0N/A * <blockquote><pre>
0N/A * DataInputStream d =&nbsp;new&nbsp;DataInputStream(in);
0N/A * </pre></blockquote>
0N/A * with:
0N/A * <blockquote><pre>
0N/A * BufferedReader d
0N/A * =&nbsp;new&nbsp;BufferedReader(new&nbsp;InputStreamReader(in));
0N/A * </pre></blockquote>
0N/A *
0N/A * @return the next line of text from this input stream.
0N/A * @exception IOException if an I/O error occurs.
0N/A * @see java.io.BufferedReader#readLine()
0N/A * @see java.io.FilterInputStream#in
0N/A */
0N/A @Deprecated
0N/A public final String readLine() throws IOException {
0N/A char buf[] = lineBuffer;
0N/A
0N/A if (buf == null) {
0N/A buf = lineBuffer = new char[128];
0N/A }
0N/A
0N/A int room = buf.length;
0N/A int offset = 0;
0N/A int c;
0N/A
0N/Aloop: while (true) {
0N/A switch (c = in.read()) {
0N/A case -1:
0N/A case '\n':
0N/A break loop;
0N/A
0N/A case '\r':
0N/A int c2 = in.read();
0N/A if ((c2 != '\n') && (c2 != -1)) {
0N/A if (!(in instanceof PushbackInputStream)) {
0N/A this.in = new PushbackInputStream(in);
0N/A }
0N/A ((PushbackInputStream)in).unread(c2);
0N/A }
0N/A break loop;
0N/A
0N/A default:
0N/A if (--room < 0) {
0N/A buf = new char[offset + 128];
0N/A room = buf.length - offset - 1;
0N/A System.arraycopy(lineBuffer, 0, buf, 0, offset);
0N/A lineBuffer = buf;
0N/A }
0N/A buf[offset++] = (char) c;
0N/A break;
0N/A }
0N/A }
0N/A if ((c == -1) && (offset == 0)) {
0N/A return null;
0N/A }
0N/A return String.copyValueOf(buf, 0, offset);
0N/A }
0N/A
0N/A /**
0N/A * See the general contract of the <code>readUTF</code>
0N/A * method of <code>DataInput</code>.
0N/A * <p>
0N/A * Bytes
0N/A * for this operation are read from the contained
0N/A * input stream.
0N/A *
0N/A * @return a Unicode string.
0N/A * @exception EOFException if this input stream reaches the end before
0N/A * reading all the bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @exception UTFDataFormatException if the bytes do not represent a valid
0N/A * modified UTF-8 encoding of a string.
0N/A * @see java.io.DataInputStream#readUTF(java.io.DataInput)
0N/A */
0N/A public final String readUTF() throws IOException {
0N/A return readUTF(this);
0N/A }
0N/A
0N/A /**
0N/A * Reads from the
0N/A * stream <code>in</code> a representation
0N/A * of a Unicode character string encoded in
0N/A * <a href="DataInput.html#modified-utf-8">modified UTF-8</a> format;
0N/A * this string of characters is then returned as a <code>String</code>.
0N/A * The details of the modified UTF-8 representation
0N/A * are exactly the same as for the <code>readUTF</code>
0N/A * method of <code>DataInput</code>.
0N/A *
0N/A * @param in a data input stream.
0N/A * @return a Unicode string.
0N/A * @exception EOFException if the input stream reaches the end
0N/A * before all the bytes.
0N/A * @exception IOException the stream has been closed and the contained
0N/A * input stream does not support reading after close, or
0N/A * another I/O error occurs.
0N/A * @exception UTFDataFormatException if the bytes do not represent a
0N/A * valid modified UTF-8 encoding of a Unicode string.
0N/A * @see java.io.DataInputStream#readUnsignedShort()
0N/A */
0N/A public final static String readUTF(DataInput in) throws IOException {
0N/A int utflen = in.readUnsignedShort();
0N/A byte[] bytearr = null;
0N/A char[] chararr = null;
0N/A if (in instanceof DataInputStream) {
0N/A DataInputStream dis = (DataInputStream)in;
0N/A if (dis.bytearr.length < utflen){
0N/A dis.bytearr = new byte[utflen*2];
0N/A dis.chararr = new char[utflen*2];
0N/A }
0N/A chararr = dis.chararr;
0N/A bytearr = dis.bytearr;
0N/A } else {
0N/A bytearr = new byte[utflen];
0N/A chararr = new char[utflen];
0N/A }
0N/A
0N/A int c, char2, char3;
0N/A int count = 0;
0N/A int chararr_count=0;
0N/A
0N/A in.readFully(bytearr, 0, utflen);
0N/A
0N/A while (count < utflen) {
0N/A c = (int) bytearr[count] & 0xff;
0N/A if (c > 127) break;
0N/A count++;
0N/A chararr[chararr_count++]=(char)c;
0N/A }
0N/A
0N/A while (count < utflen) {
0N/A c = (int) bytearr[count] & 0xff;
0N/A switch (c >> 4) {
0N/A case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
0N/A /* 0xxxxxxx*/
0N/A count++;
0N/A chararr[chararr_count++]=(char)c;
0N/A break;
0N/A case 12: case 13:
0N/A /* 110x xxxx 10xx xxxx*/
0N/A count += 2;
0N/A if (count > utflen)
0N/A throw new UTFDataFormatException(
0N/A "malformed input: partial character at end");
0N/A char2 = (int) bytearr[count-1];
0N/A if ((char2 & 0xC0) != 0x80)
0N/A throw new UTFDataFormatException(
0N/A "malformed input around byte " + count);
0N/A chararr[chararr_count++]=(char)(((c & 0x1F) << 6) |
0N/A (char2 & 0x3F));
0N/A break;
0N/A case 14:
0N/A /* 1110 xxxx 10xx xxxx 10xx xxxx */
0N/A count += 3;
0N/A if (count > utflen)
0N/A throw new UTFDataFormatException(
0N/A "malformed input: partial character at end");
0N/A char2 = (int) bytearr[count-2];
0N/A char3 = (int) bytearr[count-1];
0N/A if (((char2 & 0xC0) != 0x80) || ((char3 & 0xC0) != 0x80))
0N/A throw new UTFDataFormatException(
0N/A "malformed input around byte " + (count-1));
0N/A chararr[chararr_count++]=(char)(((c & 0x0F) << 12) |
0N/A ((char2 & 0x3F) << 6) |
0N/A ((char3 & 0x3F) << 0));
0N/A break;
0N/A default:
0N/A /* 10xx xxxx, 1111 xxxx */
0N/A throw new UTFDataFormatException(
0N/A "malformed input around byte " + count);
0N/A }
0N/A }
0N/A // The number of chars produced may be less than utflen
0N/A return new String(chararr, 0, chararr_count);
0N/A }
0N/A}