亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? bufferedinputstream.java

?? 開發(fā)j2me 手機(jī)程序必須的用到的。文件較小
?? JAVA
字號:
package com.jmobilecore.comm;

import java.io.InputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;

/**
 * The class is J2ME port of Sun's BufferedOutputStream which
 * implements a buffered input stream. When the <code>BufferedInputStream</code>
 * is created, an internal buffer array is created. As bytes  from the stream are read
 * or skipped, the internal buffer is refilled as necessary  from the contained input stream,
 * many bytes at a time.
 *
 * @author  Greg Gridin
 */
public class BufferedInputStream extends ByteArrayInputStream {

    protected static int DEFAULT_BUFFER_SIZE = 1024;

    /**
     * The input stream.
     */
    protected InputStream in;

    /**
     * The maximum read ahead allowed after a call to the
     * <code>mark</code> method before subsequent calls to the
     * <code>reset</code> method fail.
     * Whenever the difference between <code>pos</code>
     * and <code>markpos</code> exceeds <code>marklimit</code>,
     * then the  mark may be dropped by setting
     * <code>markpos</code> to <code>-1</code>.
     *
     * @see com.jmobilecore.comm.BufferedInputStream#mark(int)
     * @see com.jmobilecore.comm.BufferedInputStream#reset()
     */
    protected int marklimit;

    /**
     * Creates a <code>BufferedInputStream</code>
     * and saves its  argument, the input stream
     * <code>in</code>, for later use. An internal
     * buffer array is created and  stored in <code>buf</code>.
     *
     * @param in the underlying input stream.
     */
    public BufferedInputStream(InputStream in) {
        this(in, DEFAULT_BUFFER_SIZE);
    }

    /**
     * Creates a <code>BufferedInputStream</code>
     * with the specified buffer size,
     * and saves its  argument, the input stream
     * <code>in</code>, for later use.  An internal
     * buffer array of length  <code>size</code>
     * is created and stored in <code>buf</code>.
     *
     * @param in   the underlying input stream.
     * @param size the buffer size.
     * @throws IllegalArgumentException if size <= 0.
     */
    public BufferedInputStream(InputStream in, int size) {
        super(new byte[size]);
        count = 0;
        this.in = in;
    }

    /**
     * Fills the buffer with more data, taking into account
     * shuffling and other tricks for dealing with marks.
     * Assumes that it is being called by a synchronized method.
     * This method also assumes that all data has already been read in,
     * hence pos > count.
     */
    private void fill() throws IOException {
        if (mark < 0) {
            pos = 0;		/* no mark: throw away the buffer */
        } else if (pos >= buf.length) { /* no room left in buffer */
            if (mark > 0) {	/* can throw away early part of the buffer */
                int sz = pos - mark;
                System.arraycopy(buf, mark, buf, 0, sz);
                pos = sz;
                mark = 0;
            } else if (buf.length >= marklimit) {
                mark = -1;	/* buffer got too big, invalidate mark */
                pos = 0;	/* drop buffer contents */
            } else {		/* grow buffer */
                int nsz = pos * 2;
                if (nsz > marklimit)
                    nsz = marklimit;
                byte nbuf[] = new byte[nsz];
                System.arraycopy(buf, 0, nbuf, 0, pos);
                buf = nbuf;
            }
        }
        count = pos;
        int n = in.read(buf, pos, buf.length - pos);
        if (n > 0)
            count = n + pos;
    }

    /**
     * See
     * the general contract of the <code>read</code>
     * method of <code>InputStream</code>.
     *
     * @return the next byte of data, or <code>-1</code> if the end of the
     *         stream is reached.
     * @see com.jmobilecore.comm.BufferedInputStream#in
     */
    public int read() {
        if (pos >= count) {
            try {
                fill();
            } catch (IOException e) {
                return -1;
            }
            if (pos >= count)
                return -1;
        }
        return buf[pos++] & 0xff;
    }

    /**
     * Read characters into a portion of an array, reading from the underlying
     * stream at most once if necessary.
     */
    private int read1(byte[] b, int off, int len) throws IOException {
        int avail = count - pos;
        if (avail <= 0) {
            /* If the requested length is at least as large as the buffer, and
               if there is no mark/reset activity, do not bother to copy the
               bytes into the local buffer.  In this way buffered streams will
               cascade harmlessly. */
            if (len >= buf.length && mark < 0) {
                return in.read(b, off, len);
            }
            fill();
            avail = count - pos;
            if (avail <= 0) return -1;
        }
        int cnt = (avail < len) ? avail : len;
        System.arraycopy(buf, pos, b, off, cnt);
        pos += cnt;
        return cnt;
    }

    /**
     * Reads bytes from this byte-input stream into the specified byte array,
     * starting at the given offset.
     * <p/>
     * <p> This method implements the general contract of the corresponding
     * <code>{@link InputStream#read(byte[], int, int) read}</code> method of
     * the <code>{@link InputStream}</code> class.  As an additional
     * convenience, it attempts to read as many bytes as possible by repeatedly
     * invoking the <code>read</code> method of the underlying stream.  This
     * iterated <code>read</code> continues until one of the following
     * conditions becomes true: <ul>
     * <p/>
     * <li> The specified number of bytes have been read,
     * <p/>
     * <li> The <code>read</code> method of the underlying stream returns
     * <code>-1</code>, indicating end-of-file, or
     * <p/>
     * <li> The <code>available</code> method of the underlying stream
     * returns zero, indicating that further input requests would block.
     * <p/>
     * </ul> If the first <code>read</code> on the underlying stream returns
     * <code>-1</code> to indicate end-of-file then this method returns
     * <code>-1</code>.  Otherwise this method returns the number of bytes
     * actually read.
     * <p/>
     * <p> Subclasses of this class are encouraged, but not required, to
     * attempt to read as many bytes as possible in the same fashion.
     *
     * @param b   destination buffer.
     * @param off offset at which to start storing bytes.
     * @param len maximum number of bytes to read.
     * @return the number of bytes read, or <code>-1</code> if the end of
     *         the stream has been reached.
     */
    public int read(byte b[], int off, int len) {
        if ((off | len | (off + len) | (b.length - (off + len))) < 0) {
            throw new IndexOutOfBoundsException();
        } else if (len == 0) {
            return 0;
        }
        try {
            int n = read1(b, off, len);
            if (n <= 0) return n;
            while ((n < len) && (in.available() > 0)) {
                int n1 = read1(b, off + n, len - n);
                if (n1 <= 0) break;
                n += n1;
            }
            return n;
        } catch (IOException e) {
            return -1;
        }
    }

    /**
     * See the general contract of the <code>skip</code>
     * method of <code>InputStream</code>.
     *
     * @param n the number of bytes to be skipped.
     * @return the actual number of bytes skipped.
     */
    public long skip(long n) {
        if (n <= 0) {
            return 0;
        }
        long avail = count - pos;

        if (avail <= 0) {
            // If no mark position set then don't keep in buffer
            if (mark < 0)
                try {
                    return in.skip(n);
                } catch (IOException e) {
                    return -1;
                }

            // Fill in buffer to save bytes for reset
            try {
                fill();
            } catch (IOException e) {
                return -1;
            }
            avail = count - pos;
            if (avail <= 0)
                return 0;
        }

        long skipped = (avail < n) ? avail : n;
        pos += skipped;
        return skipped;
    }

    /**
     * Returns the number of bytes that can be read from this input
     * stream without blocking.
     * <p/>
     * The <code>available</code> method of
     * <code>BufferedInputStream</code> returns the sum of the the number
     * of bytes remaining to be read in the buffer
     * (<code>count&nbsp;- pos</code>)
     * and the result of calling the <code>available</code> method of the
     * underlying input stream.
     *
     * @return the number of bytes that can be read from this input
     *         stream without blocking.
     * @see com.jmobilecore.comm.BufferedInputStream#in
     */
    public int available() {
        try {
            return (count - pos) + in.available();
        } catch (IOException e) {
            return -1;
        }
    }

    /**
     * See the general contract of the <code>mark</code>
     * method of <code>InputStream</code>.
     *
     * @param readlimit the maximum limit of bytes that can be read before
     *                  the mark position becomes invalid.
     * @see com.jmobilecore.comm.BufferedInputStream#reset()
     */
    public void mark(int readlimit) {
        marklimit = readlimit;
        mark = pos;
    }

    /**
     * See the general contract of the <code>reset</code>
     * method of <code>InputStream</code>.
     * <p/>
     * If <code>markpos</code> is <code>-1</code>
     * (no mark has been set or the mark has been
     * invalidated), an <code>IOException</code>
     * is thrown. Otherwise, <code>pos</code> is
     * set equal to <code>markpos</code>.
     *
     * @see com.jmobilecore.comm.BufferedInputStream#mark(int)
     */
    public void reset() {
        pos = mark;
    }

    /**
     * Tests if this input stream supports the <code>mark</code>
     * and <code>reset</code> methods. The <code>markSupported</code>
     * method of <code>BufferedInputStream</code> returns
     * <code>true</code>.
     *
     * @return a <code>boolean</code> indicating if this stream type supports
     *         the <code>mark</code> and <code>reset</code> methods.
     * @see java.io.InputStream#mark(int)
     * @see java.io.InputStream#reset()
     */
    public boolean markSupported() {
        return true;
    }

    /**
     * Closes this input stream and releases any system resources
     * associated with the stream.
     *
     * @throws IOException if an I/O error occurs.
     */
    public void close() throws IOException {
        if (in != null) {
            in.close();
        }
        in = null;
        buf = null;
    }
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美—级在线免费片| 欧美日韩国产片| 国产精品538一区二区在线| 国产成人欧美日韩在线电影| 91麻豆免费视频| 欧美精品v国产精品v日韩精品| 久久久亚洲欧洲日产国码αv| 国产精品理论在线观看| 五月天丁香久久| 丁香桃色午夜亚洲一区二区三区| 国产99久久久久| 中文字幕日韩一区二区| 国产在线精品一区二区三区不卡| 日本乱人伦aⅴ精品| 久久综合精品国产一区二区三区| 夜夜嗨av一区二区三区中文字幕 | 在线不卡一区二区| 另类成人小视频在线| 91成人免费在线| 青青草原综合久久大伊人精品优势| 91亚洲精品一区二区乱码| 亚洲夂夂婷婷色拍ww47| 99久久精品国产导航| xf在线a精品一区二区视频网站| 国产成人福利片| 一区二区三区四区精品在线视频| 91精选在线观看| 午夜免费久久看| 欧美xfplay| 免费观看30秒视频久久| 国产精品蜜臀在线观看| 成人黄色777网| 国产三级欧美三级| 青草av.久久免费一区| 国产精品色呦呦| 欧美男同性恋视频网站| 成人免费观看男女羞羞视频| 日本不卡视频一二三区| 亚洲欧美日韩系列| av午夜一区麻豆| 最新日韩av在线| 欧美mv日韩mv亚洲| 欧日韩精品视频| 午夜不卡av在线| 亚洲人成电影网站色mp4| 精品国产乱码久久久久久老虎| 激情深爱一区二区| 国产日韩一级二级三级| 欧美绝品在线观看成人午夜影视| 成人av集中营| 国内精品在线播放| 日本亚洲电影天堂| 久久麻豆一区二区| 欧美一级视频精品观看| 精品一区二区三区在线播放| 国产亚洲制服色| 欧美一区二区高清| 欧美日韩国产成人在线免费| 色综合天天综合网天天狠天天| 一区二区三区精品在线观看| 中文字幕制服丝袜成人av| 精品国产一区二区亚洲人成毛片| 欧美精三区欧美精三区| 欧美日韩中文一区| 国产在线精品一区二区| 日本亚洲电影天堂| 日韩二区在线观看| 日日摸夜夜添夜夜添精品视频| 精品国产伦一区二区三区观看体验| 欧美日韩中文字幕一区二区| 在线精品亚洲一区二区不卡| 日本电影欧美片| 91视频观看视频| 色综合中文字幕国产 | 亚洲欧美电影一区二区| 国产精品伦一区二区三级视频| 中文一区一区三区高中清不卡| 国产亚洲va综合人人澡精品| 久久人人超碰精品| 久久久综合网站| 亚洲国产成人午夜在线一区| 国产午夜亚洲精品午夜鲁丝片| 国产日产欧产精品推荐色| 久久精品综合网| 国产精品久久精品日日| 18涩涩午夜精品.www| 亚洲激情五月婷婷| 久久免费国产精品| 国产肉丝袜一区二区| 中文一区在线播放| 亚洲视频狠狠干| 欧美激情一区二区三区四区 | 在线播放亚洲一区| 欧美va在线播放| 国产女人18水真多18精品一级做| 国产精品毛片久久久久久久| 亚洲男人的天堂在线观看| 亚洲一区二区三区在线看| 五月天网站亚洲| 国产中文一区二区三区| 99免费精品在线| 欧美视频在线不卡| 色综合欧美在线| 成人免费福利片| 在线观看91视频| 日韩三级av在线播放| 这里只有精品免费| 久久久久久久久蜜桃| 亚洲精品v日韩精品| 久久精品国内一区二区三区| 成人国产精品免费| 欧美日韩高清影院| 久久午夜色播影院免费高清| 亚洲三级小视频| 美女在线一区二区| 蜜臀久久99精品久久久久宅男| 极品少妇一区二区三区精品视频 | 色先锋久久av资源部| 欧美一区二区视频在线观看2022 | 在线精品视频一区二区三四| 日韩欧美色综合网站| 欧美日韩久久久一区| 国产午夜精品在线观看| 亚洲影院在线观看| 国产a精品视频| 91精品欧美福利在线观看| 国产精品女上位| 蜜臀久久99精品久久久久宅男 | 免费的成人av| 日本黄色一区二区| 欧美韩日一区二区三区| 日韩福利电影在线观看| 91在线丨porny丨国产| 精品不卡在线视频| 亚洲在线中文字幕| av一区二区三区| 精品久久久久久久一区二区蜜臀| 亚洲一区二区三区不卡国产欧美 | 在线观看91精品国产入口| 欧美激情一区不卡| 韩国v欧美v亚洲v日本v| 91精品国产色综合久久ai换脸| 亚洲黄色小说网站| 粉嫩一区二区三区在线看| 欧美不卡一区二区三区四区| 亚洲一区二区三区爽爽爽爽爽| 91在线精品一区二区| 久久精品亚洲精品国产欧美| 美女视频网站久久| 欧美另类一区二区三区| 亚洲最新视频在线观看| www.亚洲在线| 国产日产欧美精品一区二区三区| 久久99最新地址| 精品日韩99亚洲| 久久99精品一区二区三区三区| 日韩一区二区在线免费观看| 天天综合色天天综合| 欧美精品欧美精品系列| 亚洲成人激情社区| 国产成人在线影院| 久久久久久久久伊人| 国产精品一二三在| 国产亚洲精品精华液| 国产成人精品午夜视频免费| 国产网站一区二区三区| 国产乱子轮精品视频| 久久久久久久久久美女| 国产成人aaa| 国产精品入口麻豆原神| 成人理论电影网| 一区二区三区中文字幕电影| 在线亚洲免费视频| 午夜免费久久看| 日韩写真欧美这视频| 精品一区二区国语对白| 久久久久久麻豆| a在线欧美一区| 一区二区在线观看av| 欧美无砖砖区免费| 视频一区二区中文字幕| 欧美r级电影在线观看| 成人性生交大片免费| 日韩一区在线播放| 在线观看一区不卡| 日本中文字幕一区二区有限公司| 欧美不卡激情三级在线观看| 久久电影网电视剧免费观看| 国产亚洲精品资源在线26u| 99久久久久久| 亚洲成人精品影院| 久久一区二区视频| 99精品视频在线播放观看| 亚洲国产中文字幕在线视频综合| 成人av综合一区| 亚洲一区二区三区视频在线 | 欧美日韩mp4| 国内精品在线播放| 亚洲精选视频在线| 日韩三级在线观看|