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

📄 israndomaccessio.java

📁 jpeg2000算法实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     *          * */    public void readFully(byte b[], int off, int n) throws IOException {        if (pos+n <= len) { // common, fast case            System.arraycopy(buf,pos,b,off,n);            pos += n;            return;        }        // general case        while (!complete && pos+n > len) {            readInput();        }        if (pos+n > len) {            throw new EOFException();        }        System.arraycopy(buf,pos,b,off,n);        pos += n;    }        /**     * Returns the endianess (i.e., byte ordering) of multi-byte I/O     * operations. Always EndianType.BIG_ENDIAN since this class implements     * only big-endian.     *     * @return Always EndianType.BIG_ENDIAN.     *     * @see EndianType     *     */    public int getByteOrdering() {        return EndianType.BIG_ENDIAN;    }    /**     * Reads a signed byte (8 bit) from the input.     *     * @return The next byte-aligned signed byte (8 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public byte readByte() throws IOException {        if (pos < len) { // common, fast case            return buf[pos++];        }        // general case        return (byte) read();    }    /**     * Reads an unsigned byte (8 bit) from the input.     *     * @return The next byte-aligned unsigned byte (8 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public int readUnsignedByte() throws IOException {        if (pos < len) { // common, fast case            return 0xFF & buf[pos++];        }        // general case        return read();    }    /**     * Reads a signed short (16 bit) from the input.     *     * @return The next byte-aligned signed short (16 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public short readShort() throws IOException {        if (pos+1 < len) { // common, fast case            return (short) ((buf[pos++]<<8) | (0xFF & buf[pos++]));        }        // general case        return (short) ((read()<<8) | read());    }    /**     * Reads an unsigned short (16 bit) from the input.     *     * @return The next byte-aligned unsigned short (16 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public int readUnsignedShort() throws IOException {        if (pos+1 < len) { // common, fast case            return ((0xFF & buf[pos++])<<8) | (0xFF & buf[pos++]);        }        // general case        return (read()<<8) | read();    }    /**     * Reads a signed int (32 bit) from the input.     *     * @return The next byte-aligned signed int (32 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public int readInt() throws IOException {        if (pos+3 < len) { // common, fast case            return ((buf[pos++]<<24) | ((0xFF & buf[pos++])<<16)                    | ((0xFF & buf[pos++])<<8) | (0xFF & buf[pos++]));        }        // general case        return (read()<<24) | (read()<<16) | (read()<<8) | read();    }    /**     * Reads a unsigned int (32 bit) from the input.     *     * @return The next byte-aligned unsigned int (32 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public long readUnsignedInt() throws IOException {        if (pos+3 < len) { // common, fast case            return (0xFFFFFFFFL                    & (long)((buf[pos++]<<24) | ((0xFF & buf[pos++])<<16)                             | ((0xFF & buf[pos++])<<8) | (0xFF & buf[pos++])));        }        // general case        return (0xFFFFFFFFL                & (long)((read()<<24) | (read()<<16) | (read()<<8) | read()));    }    /**     * Reads a signed long (64 bit) from the input.     *     * @return The next byte-aligned signed long (64 bit) from the     * input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public long readLong() throws IOException {        if (pos+7 < len) { // common, fast case            return (((long)buf[pos++]<<56)                    | ((long)(0xFF&buf[pos++])<<48)                    | ((long)(0xFF&buf[pos++])<<40)                    | ((long)(0xFF&buf[pos++])<<32)                    | ((long)(0xFF&buf[pos++])<<24)                    | ((long)(0xFF&buf[pos++])<<16)                    | ((long)(0xFF&buf[pos++])<<8)                    | (long)(0xFF&buf[pos++]));        }        // general case        return (((long)read()<<56)                | ((long)read()<<48)                | ((long)read()<<40)                | ((long)read()<<32)                | ((long)read()<<24)                | ((long)read()<<16)                | ((long)read()<<8)                | (long)read());    }    /**     * Reads an IEEE single precision (i.e., 32 bit) floating-point number     * from the input.     *     * @return The next byte-aligned IEEE float (32 bit) from the input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public float readFloat() throws IOException {        if (pos+3 < len) { // common, fast case            return Float.intBitsToFloat((buf[pos++]<<24)                                        | ((0xFF & buf[pos++])<<16)                                        | ((0xFF & buf[pos++])<<8)                                        | (0xFF & buf[pos++]));        }        // general case        return Float.intBitsToFloat((read()<<24) | (read()<<16)                                    | (read()<<8) | read());    }    /**     * Reads an IEEE double precision (i.e., 64 bit) floating-point number     * from the input.     *     * @return The next byte-aligned IEEE double (64 bit) from the input.     *     * @exception EOFException If the end-of file was reached before     * getting all the necessary data.     *     * @exception IOException If an I/O error ocurred.     * */    public double readDouble() throws IOException {        if (pos+7 < len) { // common, fast case            return Double.longBitsToDouble(((long)buf[pos++]<<56)                                           | ((long)(0xFF&buf[pos++])<<48)                                           | ((long)(0xFF&buf[pos++])<<40)                                           | ((long)(0xFF&buf[pos++])<<32)                                           | ((long)(0xFF&buf[pos++])<<24)                                           | ((long)(0xFF&buf[pos++])<<16)                                           | ((long)(0xFF&buf[pos++])<<8)                                           | (long)(0xFF&buf[pos++]));        }        // general case        return Double.longBitsToDouble(((long)read()<<56)                                       | ((long)read()<<48)                                       | ((long)read()<<40)                                       | ((long)read()<<32)                                       | ((long)read()<<24)                                       | ((long)read()<<16)                                       | ((long)read()<<8)                                       | (long)read());    }    /**     * Skips 'n' bytes from the input.     *     * @param n The number of bytes to skip     *     * @return Always n.     *     * @exception EOFException If the end-of file was reached before     * all the bytes could be skipped.     *     * @exception IOException If an I/O error ocurred.     * */    public int skipBytes(int n) throws IOException {        if (complete) { /* we know the length, check skip is within length */            if (pos+n > len) {                throw new EOFException();            }        }        pos += n;        return n;    }    /**     * Does nothing since this class does not implement data output.     */    public void flush() { /* no-op */    }    /**     * Throws an IOException since this class does not implement data output.     */    public void write(int b) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeByte(int v) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeShort(int v) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeInt(int v) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeLong(long v) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeFloat(float v) throws IOException {        throw new IOException("read-only");    }    /**     * Throws an IOException since this class does not implement data output.     */    public void writeDouble(double v) throws IOException {        throw new IOException("read-only");    }}

⌨️ 快捷键说明

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