⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 generalbase.java

📁 已经移植好的java虚拟机
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     */    public void close() throws IOException {    }//// DataInput functions//    /**     * Reads the next byte of data from the input stream. The value byte is     * returned as an <code>int</code> in the range <code>0</code> to     * <code>255</code>. If no byte is available because the end of the stream     * has been reached, the value <code>-1</code> is returned. This method     * blocks until input data is available, the end of the stream is detected,     * or an exception is thrown.     *     * <p> A subclass must provide an implementation of this method.     *     * @return     the next byte of data, or <code>-1</code> if the end of the     *             stream is reached.     * @exception  IOException  if an I/O error occurs.     */    public int read() throws IOException {        throw new RuntimeException("No read()");    }    /**     * Skips over and discards <code>n</code> bytes of data from this input     * stream. The <code>skip</code> method may, for a variety of reasons, end     * up skipping over some smaller number of bytes, possibly <code>0</code>.     * This may result from any of a number of conditions; reaching end of file     * before <code>n</code> bytes have been skipped is only one possibility.     * The actual number of bytes skipped is returned.  If <code>n</code> is     * negative, no bytes are skipped.     *     * <p> The <code>skip</code> method of <code>InputStream</code> creates a     * byte array and then repeatedly reads into it until <code>n</code> bytes     * have been read or the end of the stream has been reached. Subclasses are     * encouraged to provide a more efficient implementation of this method.     *     * @param      n   the number of bytes to be skipped.     * @return     the actual number of bytes skipped.     * @exception  IOException  if an I/O error occurs.     */    public long skip(long n) throws IOException {        long m = n;        while (m > 0) {            if(read() < 0) {                break;            }            --m;        }        return n-m;    }    /**     * See the general contract of the <code>readFully</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @param      b   the buffer into which the data is read.     * @exception  EOFException  if this input stream reaches the end     *                           before reading all the bytes.     * @exception  IOException   if an I/O error occurs.     */    public void readFully(byte b[]) throws IOException {        readFully(b, 0, b.length);    }    /**     * See the general contract of the <code>readFully</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @param      b     the buffer into which the data is read.     * @param      off   the start offset of the data.     * @param      len   the number of bytes to read.     * @exception  EOFException  if this input stream reaches the end     *                           before reading all the bytes.     * @exception  IOException   if an I/O error occurs.     */    public void readFully(byte b[], int off, int len) throws IOException {        if (len < 0)            throw new IndexOutOfBoundsException();        int n = 0;        while (n < len) {            int ch = read();            if (ch < 0) {                throw new EOFException();            }            b[off+(n++)] = (byte)ch;        }    }    /**     * See the general contract of the <code>skipBytes</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @param      n   the number of bytes to be skipped.     * @return     the actual number of bytes skipped.     * @exception  IOException   if an I/O error occurs.     */    public int skipBytes(int n) throws IOException {        int total = 0;        int cur = 0;        while ((total<n) && ((cur = (int) skip(n-total)) > 0)) {            total += cur;        }        return total;    }    /**     * See the general contract of the <code>readBoolean</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the <code>boolean</code> value read.     * @exception  EOFException  if this input stream has reached the end.     */    public boolean readBoolean() throws IOException {        int ch = read();        if (ch < 0)            throw new EOFException();        return (ch != 0);    }    /**     * See the general contract of the <code>readByte</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next byte of this input stream as a signed 8-bit     *             <code>byte</code>.     * @exception  EOFException  if this input stream has reached the end.     * @exception  IOException   if an I/O error occurs.     */    public byte readByte() throws IOException {        int ch = read();        if (ch < 0)            throw new EOFException();        return (byte)(ch);    }    /**     * See the general contract of the <code>readUnsignedByte</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next byte of this input stream, interpreted as an     *             unsigned 8-bit number.     * @exception  EOFException  if this input stream has reached the end.     * @exception  IOException   if an I/O error occurs.     */    public int readUnsignedByte() throws IOException {        int ch = read();        if (ch < 0)            throw new EOFException();        return ch;    }    /**     * See the general contract of the <code>readShort</code>     * method of <code>DataInput</code>.     * <p>     * Bytes     * for this operation are read from the contained     * input stream.     *     * @return     the next two bytes of this input stream, interpreted     *             as a signed 16-bit number.     * @exception  EOFException  if this input stream reaches the end     *                           before reading two bytes.     * @exception  IOException   if an I/O error occurs.     */    public short readShort() throws IOException {        int ch1 = read();        int ch2 = read();        if ((ch1 | ch2) < 0)             throw new EOFException();        return (short)((ch1 << 8) + (ch2 << 0));    }    /**     * See the general contract of the <code>readUnsignedShort</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next two bytes of this input stream, interpreted     *             as an unsigned 16-bit integer.     * @exception  EOFException  if this input stream reaches the end     *                           before reading two bytes.     * @exception  IOException   if an I/O error occurs.     */    public int readUnsignedShort() throws IOException {        int ch1 = read();        int ch2 = read();        if ((ch1 | ch2) < 0)             throw new EOFException();        return (ch1 << 8) + (ch2 << 0);    }    /**     * See the general contract of the <code>readChar</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next two bytes of this input stream as     *             a Unicode character.     * @exception  EOFException  if this input stream reaches the end     *                           before reading two bytes.     * @exception  IOException   if an I/O error occurs.     */    public char readChar() throws IOException {        int ch1 = read();        int ch2 = read();        if ((ch1 | ch2) < 0)             throw new EOFException();        return (char)((ch1 << 8) + (ch2 << 0));    }    /**     * See the general contract of the <code>readInt</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next four bytes of this input stream, interpreted     *             as an <code>int</code>.     * @exception  EOFException  if this input stream reaches the end     *                           before reading four bytes.     * @exception  IOException   if an I/O error occurs.     */    public int readInt() throws IOException {        int ch1 = read();        int ch2 = read();        int ch3 = read();        int ch4 = read();        if ((ch1 | ch2 | ch3 | ch4) < 0)             throw new EOFException();        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));    }    /**     * See the general contract of the <code>readLong</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     the next eight bytes of this input stream, interpreted     *             as a     *             <code>long</code>.     * @exception  EOFException  if this input stream reaches the end     *                           before reading eight bytes.     * @exception  IOException   if an I/O error occurs.     */    public long readLong() throws IOException {        return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);    }    /**     * See the general contract of the <code>readUTF</code>     * method of <code>DataInput</code>.     * <p>     * Bytes for this operation are read from the contained     * input stream.     *     * @return     a Unicode string.     * @exception  EOFException  if this input stream reaches the end     *                           before reading all the bytes.     * @exception  IOException   if an I/O error occurs.     * @see        java.io.DataInputStream#readUTF(java.io.DataInput)     */    public String readUTF() throws IOException {        return DataInputStream.readUTF(this);    }    /**     * Unsupported function     */    public String readLine() throws IOException {        throw new RuntimeException("Function not supported");    }    /**     * Allow other threads to run whilst I/O is not available.     */    public native static void iowait();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -