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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? recordinginputstream.java

?? 爬蟲
?? JAVA
字號:
/* RecordingInputStream * * $Id: RecordingInputStream.java,v 1.33 2006/08/15 04:39:00 gojomo Exp $ * * Created on Sep 24, 2003 * * Copyright (C) 2003 Internet Archive. * * This file is part of the Heritrix web crawler (crawler.archive.org). * * Heritrix is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser Public License as published by * the Free Software Foundation; either version 2.1 of the License, or * any later version. * * Heritrix is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU Lesser Public License for more details. * * You should have received a copy of the GNU Lesser Public License * along with Heritrix; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */package org.archive.io;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.net.SocketException;import java.net.SocketTimeoutException;import java.security.MessageDigest;import java.util.logging.Level;import java.util.logging.Logger;/** * Stream which records all data read from it, which it acquires from a wrapped * input stream. * * Makes use of a RecordingOutputStream for recording because of its being * file backed so we can write massive amounts of data w/o worrying about * overflowing memory. * * @author gojomo * */public class RecordingInputStream    extends InputStream {    protected static Logger logger =        Logger.getLogger("org.archive.io.RecordingInputStream");    /**     * Where we are recording to.     */    private RecordingOutputStream recordingOutputStream;    /**     * Stream to record.     */    private InputStream in = null;    /**     * Reusable buffer to avoid reallocation on each readFullyUntil     */    protected byte[] drainBuffer = new byte[16*1024];    /**     * Create a new RecordingInputStream.     *     * @param bufferSize Size of buffer to use.     * @param backingFilename Name of backing file.     */    public RecordingInputStream(int bufferSize, String backingFilename)    {        this.recordingOutputStream = new RecordingOutputStream(bufferSize,            backingFilename);    }    public void open(InputStream wrappedStream) throws IOException {        logger.fine(Thread.currentThread().getName() + " opening " +            wrappedStream + ", " + Thread.currentThread().getName());        if(isOpen()) {            // error; should not be opening/wrapping in an unclosed             // stream remains open            throw new IOException("RIS already open for "                    +Thread.currentThread().getName());        }        this.in = wrappedStream;        this.recordingOutputStream.open();    }    public int read() throws IOException {        if (!isOpen()) {            throw new IOException("Stream closed " +                Thread.currentThread().getName());        }        int b = this.in.read();        if (b != -1) {            assert this.recordingOutputStream != null: "ROS is null " +                Thread.currentThread().getName();            this.recordingOutputStream.write(b);        }        return b;    }    public int read(byte[] b, int off, int len) throws IOException {        if (!isOpen()) {            throw new IOException("Stream closed " +                Thread.currentThread().getName());        }        int count = this.in.read(b,off,len);        if (count > 0) {            assert this.recordingOutputStream != null: "ROS is null " +                Thread.currentThread().getName();            this.recordingOutputStream.write(b,off,count);        }        return count;    }    public int read(byte[] b) throws IOException {    	    if (!isOpen()) {    	    	    throw new IOException("Stream closed " +    			    Thread.currentThread().getName());    	    }    	    int count = this.in.read(b);        if (count > 0) {            assert this.recordingOutputStream != null: "ROS is null " +                Thread.currentThread().getName();            this.recordingOutputStream.write(b,0,count);        }        return count;    }    public void close() throws IOException {        if (logger.isLoggable(Level.FINE)) {            logger.fine(Thread.currentThread().getName() + " closing " +                    this.in + ", " + Thread.currentThread().getName());        }        if (this.in != null) {            this.in.close();            this.in = null;        }        this.recordingOutputStream.close();    }    public ReplayInputStream getReplayInputStream() throws IOException {        return this.recordingOutputStream.getReplayInputStream();    }    public ReplayInputStream getContentReplayInputStream() throws IOException {        return this.recordingOutputStream.getContentReplayInputStream();    }    public long readFully() throws IOException {        while(read(drainBuffer) != -1) {            // Empty out stream.            continue;        }        return this.recordingOutputStream.getSize();    }    /**     * Read all of a stream (Or read until we timeout or have read to the max).     * @param softMaxLength Maximum length to read; if zero or < 0, then no      * limit. If met, return normally.      * @param hardMaxLength Maximum length to read; if zero or < 0, then no      * limit. If exceeded, throw RecorderLengthExceededException     * @param timeout Timeout in milliseconds for total read; if zero or     * negative, timeout is <code>Long.MAX_VALUE</code>. If exceeded, throw     * RecorderTimeoutException     * @param maxBytesPerMs How many bytes per millisecond.     * @throws IOException failed read.     * @throws RecorderLengthExceededException     * @throws RecorderTimeoutException     * @throws InterruptedException     */    public void readFullyOrUntil(long softMaxLength, long hardMaxLength,	long timeout, int maxBytesPerMs)        throws IOException, RecorderLengthExceededException,            RecorderTimeoutException, InterruptedException {        // Check we're open before proceeding.        if (!isOpen()) {            // TODO: should this be a noisier exception-raising error?             return;        }        // We need the rate limit in ms per byte, so turn it over        double minMsPerByte = 0.0;        if (maxBytesPerMs != 0) {            minMsPerByte = ((double)1.0)/(double)maxBytesPerMs;        }        long maxLength;        if ( softMaxLength>0 && hardMaxLength>0) {            // both maxes set; use lower of softMax or hardMax+1            maxLength = Math.min(softMaxLength,hardMaxLength+1);        } else if(softMaxLength>0 && hardMaxLength<=0) {            // softMax only; set max to softMax            maxLength = softMaxLength;        } else if(softMaxLength<=0 && hardMaxLength>0) {            // hardMax only; set max to read as 1 past max            maxLength = hardMaxLength+1;        } else { // => (softMaxLength<=0 && hardMaxLength<=0)             // no maxes            maxLength = -1;        }        long timeoutTime;        long startTime = System.currentTimeMillis();        if(timeout > 0) {            timeoutTime = startTime + timeout;        } else {            timeoutTime = Long.MAX_VALUE;        }        long totalReadingTime = 0L;        long totalBytes = 0L;        long bytesRead = -1L;        int maxToRead = -1;         while (true) {            try {                maxToRead = (maxLength <= 0)                     ? drainBuffer.length                     : (int) Math.min(drainBuffer.length, maxLength - totalBytes);                // Now, decide if (and for how long) to sleep, prior to reading,                // in order to yield the average fetch rate desired.                if (minMsPerByte != 0.0 && totalBytes > 0L) {                    // We've already fetched something, so we can estimate the                    // actual bandwidth we've been getting. This number is used                    // to figure out how many ms we need to wait before                    // starting the next read.  We want the stats at the end of                    // that read to be within the specified bounds.                    double actualMsPerByte =                        ((double)totalReadingTime)/(double)totalBytes;                    // Calculate the minimum time                    long minTime =                        (long)((totalBytes + maxToRead) * minMsPerByte);                    // Calculate the actual time spent, plus the estimated time                    // for the bytes to read                    long estTime = System.currentTimeMillis() - startTime +                        (long)(maxToRead * actualMsPerByte);                    // If estTime <  minTime, sleep for the difference                    if (estTime < minTime) {                        Thread.sleep(minTime - estTime);                    }                }                long readStartTime = System.currentTimeMillis();                bytesRead = read(drainBuffer,0,maxToRead);                if (bytesRead == -1) {                    break;                }                totalBytes += bytesRead;                totalReadingTime += System.currentTimeMillis() - readStartTime;                if (Thread.interrupted()) {                    throw new InterruptedException("Interrupted during IO");                }            } catch (SocketTimeoutException e) {                // A socket timeout is just a transient problem, meaning                // nothing was available in the configured  timeout period,                // but something else might become available later.                // Take this opportunity to check the overall                 // timeout (below).  One reason for this timeout is                 // servers that keep up the connection, 'keep-alive', even                // though we asked them to not keep the connection open.                if (System.currentTimeMillis() < timeoutTime) {                    if (logger.isLoggable(Level.FINE)) {                        logger.fine("Socket timed out after " +                            (timeoutTime - startTime) + "ms: " +                            e.getMessage());                    }                }            } catch (SocketException se) {                throw se;            } catch (NullPointerException e) {                // [ 896757 ] NPEs in Andy's Th-Fri Crawl.                // A crawl was showing NPE's in this part of the code but can                // not reproduce.  Adding this rethrowing catch block w/                // diagnostics to help should we come across the problem in the                // future.                throw new NullPointerException("Stream " + this.in + ", " +                    e.getMessage() + " " + Thread.currentThread().getName());            }            if (System.currentTimeMillis() >= timeoutTime) {                throw new RecorderTimeoutException("Timedout after " +                    (timeoutTime - startTime) + "ms.");            }            if (hardMaxLength > 0 && totalBytes >= hardMaxLength) {                throw new RecorderLengthExceededException();            }            if (maxLength > 0 && totalBytes >= maxLength) {                break; // return            }        }    }    public long getSize() {        return this.recordingOutputStream.getSize();    }    public void markContentBegin() {        this.recordingOutputStream.markContentBegin();    }    public void startDigest() {        this.recordingOutputStream.startDigest();    }    /**     * Convenience method for setting SHA1 digest.     */    public void setSha1Digest() {        this.recordingOutputStream.setSha1Digest();    }    /**     * Sets a digest function which may be applied to recorded data.     * As usually only a subset of the recorded data should     * be fed to the digest, you must also call startDigest()     * to begin digesting.     *     * @param md     */    public void setDigest(MessageDigest md) {        this.recordingOutputStream.setDigest(md);    }    /**     * Return the digest value for any recorded, digested data. Call     * only after all data has been recorded; otherwise, the running     * digest state is ruined.     *     * @return the digest final value     */    public byte[] getDigestValue() {        return this.recordingOutputStream.getDigestValue();    }    public ReplayCharSequence getReplayCharSequence() throws IOException {        return getReplayCharSequence(null);    }    /**     * @param characterEncoding Encoding of recorded stream.     * @return A ReplayCharSequence  Will return null if an IOException.  Call     * close on returned RCS when done.     * @throws IOException     */    public ReplayCharSequence getReplayCharSequence(String characterEncoding)    		throws IOException {        return this.recordingOutputStream.            getReplayCharSequence(characterEncoding);    }    public long getResponseContentLength() {        return this.recordingOutputStream.getResponseContentLength();    }    public void closeRecorder() throws IOException {        this.recordingOutputStream.closeRecorder();    }    /**     * @param tempFile     * @throws IOException     */    public void copyContentBodyTo(File tempFile) throws IOException {        FileOutputStream fos = new FileOutputStream(tempFile);        ReplayInputStream ris = getContentReplayInputStream();        ris.readFullyTo(fos);        fos.close();        ris.close();    }    /**     * @return True if we've been opened.     */    public boolean isOpen()    {        return this.in != null;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91精品久久久久久久网曝门| 在线不卡的av| 正在播放一区二区| 国产精品不卡视频| 久久99蜜桃精品| 欧美日韩日日摸| 国产精品国产三级国产有无不卡| 久久99精品一区二区三区| 91丨九色porny丨蝌蚪| 久久精品综合网| 蜜臀av一区二区三区| 欧美人xxxx| 一区二区三区波多野结衣在线观看| 久久精品国产精品亚洲精品| 欧美日本免费一区二区三区| |精品福利一区二区三区| 国产成人免费视频| 亚洲精品在线电影| 麻豆成人免费电影| 5858s免费视频成人| 亚洲观看高清完整版在线观看| fc2成人免费人成在线观看播放| 精品国产一区二区三区不卡| 轻轻草成人在线| 欧美日韩国产精选| 亚洲va欧美va人人爽| 欧美日韩午夜影院| 天天综合色天天| 欧美浪妇xxxx高跟鞋交| 视频一区二区三区入口| 欧美二区乱c少妇| 日产国产欧美视频一区精品| 337p亚洲精品色噜噜噜| 三级在线观看一区二区| 欧美精品色一区二区三区| 三级影片在线观看欧美日韩一区二区| 欧美在线观看你懂的| 亚洲国产一区二区三区青草影视| 91久久国产综合久久| 亚洲一区二区三区视频在线播放| 91网上在线视频| 亚洲成av人综合在线观看| 在线播放一区二区三区| 美女免费视频一区二区| 久久精品视频免费| voyeur盗摄精品| 亚洲一区二区偷拍精品| 在线观看91精品国产麻豆| 蜜桃av噜噜一区二区三区小说| 26uuu国产在线精品一区二区| 国产一区二区三区免费| 国产精品视频免费| 欧美日韩中字一区| 老司机午夜精品99久久| 国产精品嫩草影院com| 色哟哟一区二区三区| 日韩黄色免费电影| 久久久噜噜噜久久中文字幕色伊伊| 高清不卡一二三区| 亚洲一区二区三区四区五区黄 | 欧美老年两性高潮| 美女脱光内衣内裤视频久久影院| 国产性色一区二区| 在线日韩一区二区| 激情综合色丁香一区二区| 国产精品理论在线观看| 欧美绝品在线观看成人午夜影视| 另类小说图片综合网| 亚洲婷婷综合久久一本伊一区 | 亚洲精品视频在线| 日韩午夜三级在线| 99精品国产视频| 日本va欧美va精品发布| 亚洲欧洲美洲综合色网| 7777精品伊人久久久大香线蕉超级流畅 | 日韩精品一区二区三区视频在线观看| 国产精品羞羞答答xxdd| 亚洲电影一级黄| 中文字幕欧美日韩一区| 69堂亚洲精品首页| 91免费在线看| 国产福利一区在线| 日本亚洲免费观看| 亚洲精品福利视频网站| 久久久www成人免费无遮挡大片| 欧美性色欧美a在线播放| 丁香婷婷综合五月| 久久成人免费网| 午夜精品国产更新| 亚洲人妖av一区二区| 国产亚洲女人久久久久毛片| 在线不卡中文字幕播放| 在线观看91精品国产入口| 成人午夜视频在线观看| 国内精品写真在线观看| 日本美女一区二区三区视频| 亚洲柠檬福利资源导航| 国产精品丝袜黑色高跟| 久久久美女毛片| 欧美成人r级一区二区三区| 欧美日韩国产高清一区二区 | 日韩国产在线一| 亚洲一区二区三区不卡国产欧美| 国产精品国产自产拍高清av王其| 精品剧情在线观看| 日韩午夜中文字幕| 欧美一区二区三区人| 欧美一区二区在线视频| 678五月天丁香亚洲综合网| 欧美日韩一区小说| 欧美三级电影网| 欧美一a一片一级一片| 欧美在线看片a免费观看| 日本韩国精品在线| 日本久久电影网| 日本黄色一区二区| 欧洲国内综合视频| 欧美日韩一区二区三区在线| 欧美日韩一级大片网址| 欧美日本一区二区在线观看| 欧美精品亚洲一区二区在线播放| 欧美理论在线播放| 日韩欧美不卡一区| 精品国产百合女同互慰| 日本一区二区三区四区在线视频| 亚洲精品一线二线三线无人区| 欧美不卡一区二区三区| 久久亚洲捆绑美女| 欧美韩国日本一区| 亚洲精品国产a| 婷婷激情综合网| 国产一区二区视频在线| 粗大黑人巨茎大战欧美成人| 成人精品视频网站| 欧美在线观看视频在线| 日韩欧美色综合网站| 国产欧美日韩不卡| 亚洲欧美激情小说另类| 日韩精品乱码免费| 在线影视一区二区三区| 欧美电影免费观看高清完整版| 亚洲精品一区二区在线观看| 91精品国产免费| 国产色一区二区| 日韩不卡手机在线v区| 91免费国产视频网站| 久久品道一品道久久精品| 日韩国产欧美在线播放| 色天天综合色天天久久| 国产精品久久久久影院| 国产在线精品一区二区三区不卡| 欧美精品免费视频| 一区二区三区日韩精品| 97久久精品人人爽人人爽蜜臀 | 精品夜夜嗨av一区二区三区| 欧美日韩高清在线| 一区二区三区免费观看| 91一区二区三区在线播放| 国产精品乱人伦中文| 国产不卡免费视频| 国产色91在线| 国产很黄免费观看久久| 久久精品人人做| 国产河南妇女毛片精品久久久| 精品日韩欧美在线| 紧缚奴在线一区二区三区| 日韩欧美国产1| 国产自产高清不卡| 久久亚洲精品小早川怜子| 国产精品一二三区| 国产午夜精品一区二区三区视频| 九色综合国产一区二区三区| 精品少妇一区二区| 狠狠色丁香婷综合久久| 久久精品视频在线免费观看| 国产成人综合网| 国产精品久久久久婷婷二区次 | 成人免费视频一区| 国产精品久久久久久久久快鸭 | 成人免费毛片app| 国产精品女同一区二区三区| 99久久综合精品| 国产在线视频精品一区| 亚洲精品一区二区三区影院 | 日韩欧美一区二区免费| 精品一区二区三区视频| 久久精品亚洲乱码伦伦中文| 成人精品一区二区三区四区 | 丝袜美腿亚洲综合| 日韩欧美成人一区| 福利一区福利二区| 怡红院av一区二区三区| 91.麻豆视频| 国产成人av一区二区| 亚洲精选在线视频| 91精品国产麻豆| 风间由美一区二区三区在线观看| 国产精品久久久久久久岛一牛影视 | 日韩一区二区电影网| 国产精品一二三|