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

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

?? streamtests.java

?? html to xml convertor
?? JAVA
字號:
// HTMLParser Library $Name: v1_6 $ - A java-based parser for HTML// http://sourceforge.org/projects/htmlparser// Copyright (C) 2004 Derrick Oswald//// Revision Control Information//// $Source: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/StreamTests.java,v $// $Author: derrickoswald $// $Date: 2006/05/27 17:06:28 $// $Revision: 1.17 $//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.//// This library 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 General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//package org.htmlparser.tests.lexerTests;import java.io.BufferedInputStream;import java.io.ByteArrayInputStream;import java.io.IOException;import java.net.MalformedURLException;import java.net.URL;import java.net.URLConnection;import java.util.ArrayList;import org.htmlparser.lexer.Stream;import org.htmlparser.tests.ParserTestCase;public class StreamTests extends ParserTestCase{    static    {        System.setProperty ("org.htmlparser.tests.lexerTests.StreamTests", "StreamTests");    }    /**     * Test the first level stream class.     */    public StreamTests (String name)    {        super (name);    }    /**     * Test initialization with a null value.     */    public void testNull () throws IOException    {        Stream stream;        stream = new Stream (null);        assertTrue ("erroneous character", -1 == stream.read ());    }    /**     * Test initialization with an empty input stream.     */    public void testEmpty () throws IOException    {        Stream stream;        stream = new Stream (new ByteArrayInputStream (new byte[0]));        assertTrue ("erroneous character", -1 == stream.read ());    }    /**     * Test initialization with an input stream having only one byte.     */    public void testOneByte () throws IOException    {        Stream stream;        stream = new Stream (new ByteArrayInputStream (new byte[] { (byte)0x42 }));        assertTrue ("erroneous character", 0x42 == stream.read ());        assertTrue ("erroneous character", -1 == stream.read ());    }    /**     * Test that the same bytes are returned as with a naked input stream.     */    public void testSameBytes () throws IOException    {        String link;        URL url;        URLConnection connection1;        URLConnection connection2;        BufferedInputStream in;        int b1;        int b2;        Stream stream;        int index;        link = "http://htmlparser.sourceforge.net";        try        {            url = new URL (link);            connection1 = url.openConnection ();            connection1.connect ();            in = new BufferedInputStream (connection1.getInputStream ());            connection2 = url.openConnection ();            connection2.connect ();            stream = new Stream (connection2.getInputStream ());            index = 0;            while (-1 != (b1 = in.read ()))            {                b2 = stream.read ();                if (b1 != b2)                    fail ("bytes differ at position " + index + ", expected " + b1 + ", actual " + b2);                index++;            }            b2 = stream.read ();            stream.close ();            in.close ();            assertTrue ("extra bytes", b2 == -1);        }        catch (MalformedURLException murle)        {            fail ("bad url " + link);        }    }    /**     * Test that threading works and is faster than a naked input stream.     * This, admittedly contrived, test illustrates the following principles:     * <li>the underlying network code is already multi-threaded, so there may     * not be a need to use application level threading in most cases</li>     * <li>results may vary based on network connection speed, JVM, and     * especially application usage pattterns</li>     * <li>issues only show up with large files, in my case greater than     * about 72,400 bytes, since the underlying network code reads that far     * into the socket before throttling back and waiting</li>     * <li>this is only applicable to TCP/IP usage, disk access would not     * have this problem, since the cost of reading disk is much less than     * the round-trip cost of a TCP/IP handshake</li>     * So, what does it do? It sets up to read a URL two ways, once with a     * naked input stream, and then with the Stream class. In each case, before     * reading, it delays about 2 seconds (for me anyway) to allow the java.net     * implementation to read ahead and then throttle back. The threaded Stream     * though keeps reading while this delay is going on and hence gets a big     * chunk of the file in memory. This advantage translates to a faster     * spin through the bytes after the delay.     */    public void testThreaded () throws IOException    {        String link;        URL url;        URLConnection connection;        BufferedInputStream in;        int index;        long begin;        double bytes_per_second;        int delay;        Stream stream;        long time1;        long time2;        Thread thread;        long available1;        long available2;        // pick a big file        link = "http://htmlparser.sourceforge.net/javadoc_1_3/index-all.html";        try        {            url = new URL (link);            // estimate the connection speed            System.gc ();            index = 0;            connection = url.openConnection ();            connection.connect ();            in = new BufferedInputStream (connection.getInputStream ());            begin = System.currentTimeMillis ();            while (-1 != in.read ())                index++;            bytes_per_second = 1000.0 * index / (System.currentTimeMillis () - begin);            in.close ();            delay = (int)(1.5 * 1000 * bytes_per_second / 72400); // 72400 is the throttle limit on my machine            // try the naked input stream            System.gc ();            index = 0;            available1 = 0;            connection = url.openConnection ();            connection.connect ();            in = new BufferedInputStream (connection.getInputStream ());            try            {                Thread.sleep (delay);            }            catch (Exception e)            {                e.printStackTrace ();            }            begin = System.currentTimeMillis ();            do            {                index++;                if (0 == index % 1000)                    available1 += in.available ();            }            while (-1 != in.read ());            time1 = System.currentTimeMillis () - begin;            in.close ();            // try a threaded stream            System.gc ();            index = 0;            available2 = 0;            connection = url.openConnection ();            connection.connect ();            int length = connection.getContentLength ();            stream = new Stream (connection.getInputStream (), length);            thread = new Thread (stream);            thread.setPriority (Thread.NORM_PRIORITY - 1);            thread.start ();            try            {                Thread.sleep (delay);            }            catch (Exception e)            {                e.printStackTrace ();            }            begin = System.currentTimeMillis ();            do            {                index++;                if (0 == index % 1000)                    available2 += stream.available ();            }            while (-1 != stream.read ());            time2 = System.currentTimeMillis () - begin;//            System.out.println ("fills: " + stream.fills);//            System.out.println ("reallocations: " + stream.reallocations);//            System.out.println ("synchronous: " + stream.synchronous);//            System.out.println ("buffer size: " + stream.mBuffer.length);//            System.out.println ("bytes: " + stream.mLevel);            stream.close ();//            System.out.println ("time (" + time2 + ") vs. (" + time1 + ") for " + index + " bytes");            double samples = index / 1000;//            System.out.println ("average available bytes (" + available2/samples + ") vs. (" + available1/samples + ")");            assertTrue ("slower (" + time2 + ") vs. (" + time1 + ")", time2 < time1);            assertTrue ("average available bytes not greater (" + available2/samples + ") vs. (" + available1/samples + ")", available2 > available1);        }        catch (MalformedURLException murle)        {            fail ("bad url " + link);        }    }    /**     * Test that mark and reset work as per the contract.     */    public void testMarkReset () throws IOException    {        String link;        ArrayList bytes1;        ArrayList bytes2;        URL url;        URLConnection connection;        Stream stream;        int b;        int index;        // pick a small file > 2000 bytes        link = "http://htmlparser.sourceforge.net/javadoc_1_3/overview-summary.html";        bytes1 = new ArrayList ();        bytes2 = new ArrayList ();        try        {            url = new URL (link);            connection = url.openConnection ();            connection.connect ();            stream = new Stream (connection.getInputStream ());            assertTrue ("mark not supported", stream.markSupported ());            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes1.add (new Byte ((byte)b));            }            stream.reset ();            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes2.add (new Byte ((byte)b));            }            index = 0;            while (index < bytes1.size ())            {                assertEquals ("bytes differ at position " + index, bytes1.get (index), bytes2.get (index));                index++;            }            bytes1.clear ();            bytes2.clear ();            stream.mark (1000); // the 1000 is ignored            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes1.add (new Byte ((byte)b));            }            stream.reset ();            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes2.add (new Byte ((byte)b));            }            stream.close ();            index = 0;            while (index < bytes1.size ())            {                assertEquals ("bytes differ at position " + (index + 1000), bytes1.get (index), bytes2.get (index));                index++;            }        }        catch (MalformedURLException murle)        {            fail ("bad url " + link);        }    }    /**     * Test that mark and reset work as per the contract when threaded.     */    public void testMarkResetThreaded () throws IOException    {        String link;        ArrayList bytes1;        ArrayList bytes2;        URL url;        URLConnection connection;        Stream stream;        int b;        int index;        // pick a small file > 2000 bytes        link = "http://htmlparser.sourceforge.net/javadoc_1_3/overview-summary.html";        bytes1 = new ArrayList ();        bytes2 = new ArrayList ();        try        {            url = new URL (link);            connection = url.openConnection ();            connection.connect ();            stream = new Stream (connection.getInputStream ());            (new Thread (stream)).start ();            assertTrue ("mark not supported", stream.markSupported ());            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes1.add (new Byte ((byte)b));            }            stream.reset ();            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes2.add (new Byte ((byte)b));            }            index = 0;            while (index < bytes1.size ())            {                assertEquals ("bytes differ at position " + index, bytes1.get (index), bytes2.get (index));                index++;            }            bytes1.clear ();            bytes2.clear ();            stream.mark (1000); // the 1000 is ignored            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes1.add (new Byte ((byte)b));            }            stream.reset ();            for (int i = 0; i < 1000; i++)            {                b = stream.read ();                bytes2.add (new Byte ((byte)b));            }            stream.close ();            index = 0;            while (index < bytes1.size ())            {                assertEquals ("bytes differ at position " + (index + 1000), bytes1.get (index), bytes2.get (index));                index++;            }        }        catch (MalformedURLException murle)        {            fail ("bad url " + link);        }    }    /**     * Test close.     */    public void testClose () throws IOException    {        Stream stream;        stream = new Stream (new ByteArrayInputStream (new byte[] { (byte)0x42, (byte)0x78 }));        assertTrue ("erroneous character", 0x42 == stream.read ());        stream.close ();        assertTrue ("not closed", -1 == stream.read ());   }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美亚洲禁片免费| 色哟哟国产精品| 91小视频免费看| 日韩一二三区视频| 国产精品女主播av| 免费观看成人av| 欧美探花视频资源| 国产精品欧美一级免费| 日本少妇一区二区| 欧美日韩精品一区二区在线播放| 国产日韩欧美综合一区| 免费在线观看不卡| 欧美日韩中字一区| 亚洲美女区一区| 99国产欧美久久久精品| 久久久久88色偷偷免费| 日欧美一区二区| 欧美性欧美巨大黑白大战| 国产精品天天摸av网| 国产成人在线视频网址| 日韩精品一区二区在线| 日本视频一区二区三区| 欧美一级片免费看| 五月激情六月综合| 在线视频你懂得一区二区三区| 中文字幕一区三区| 不卡视频一二三| 中文字幕在线不卡一区二区三区| 国产aⅴ综合色| 久久精品亚洲精品国产欧美kt∨| 久久精品国产一区二区三区免费看 | 欧美videofree性高清杂交| 夜夜嗨av一区二区三区中文字幕 | 欧美一区二区三区在线| 亚洲成人动漫在线观看| 欧美色涩在线第一页| 一区二区三区**美女毛片| 一本大道久久a久久精二百| 亚洲少妇最新在线视频| 色88888久久久久久影院野外| 亚洲精品中文在线影院| 欧美在线免费观看视频| 日韩电影在线免费观看| 日韩一区二区三区三四区视频在线观看 | 国产成人av电影在线播放| 久久久蜜桃精品| 成人福利在线看| 亚洲欧美另类小说视频| 欧美高清激情brazzers| 久久99精品久久久久久动态图| 精品国产不卡一区二区三区| 国内成+人亚洲+欧美+综合在线| 国产午夜精品福利| 一本色道综合亚洲| 日韩综合一区二区| 久久天堂av综合合色蜜桃网 | 久久精品国产免费| 国产日韩欧美综合在线| 91欧美一区二区| 免费在线观看视频一区| 国产精品视频一区二区三区不卡| 91黄视频在线| 国产在线视频不卡二| 中文字幕一区二区三区在线播放| 欧美午夜精品理论片a级按摩| 麻豆精品一区二区av白丝在线| 久久久不卡影院| 欧美日韩你懂的| 国产一区二区中文字幕| 亚洲精品国产精品乱码不99| 欧美一区二区三级| 成人黄色在线视频| 奇米影视一区二区三区| 亚洲欧美一区二区视频| 宅男噜噜噜66一区二区66| 成人综合在线视频| 免费三级欧美电影| 亚洲色图丝袜美腿| 精品理论电影在线| 色狠狠综合天天综合综合| 精品一区二区三区视频| 一区二区欧美视频| 国产午夜精品一区二区三区四区| 欧美三级中文字幕在线观看| 粉嫩av一区二区三区| 日本欧美韩国一区三区| 亚洲精品日韩一| 欧美国产精品一区二区三区| 91麻豆精品国产| 欧美色大人视频| 91同城在线观看| 成人一区在线观看| 激情深爱一区二区| 日本午夜精品一区二区三区电影| 亚洲三级在线观看| 国产女人水真多18毛片18精品视频| 91精品国产色综合久久久蜜香臀| 色妹子一区二区| 大美女一区二区三区| 国产在线一区二区综合免费视频| 天天做天天摸天天爽国产一区| 国产精品大尺度| 国产精品乱码一区二区三区软件 | 中文字幕制服丝袜一区二区三区| 精品国产免费人成电影在线观看四季| 91福利在线播放| 色综合久久久久综合体| 91麻豆精东视频| 亚洲色图清纯唯美| 欧美一级专区免费大片| 91蜜桃网址入口| 亚洲精品国产成人久久av盗摄| 国产三级精品视频| 久久久国际精品| www国产精品av| 日韩美女主播在线视频一区二区三区| 欧美蜜桃一区二区三区| 欧洲一区二区三区免费视频| 91在线精品一区二区三区| 成人激情电影免费在线观看| 成人综合婷婷国产精品久久蜜臀| 激情小说亚洲一区| 国产馆精品极品| 91丨九色丨黑人外教| 91在线视频18| 欧美少妇bbb| 欧美xxxxx牲另类人与| 久久综合久色欧美综合狠狠| 国产欧美综合在线| 亚洲视频图片小说| 亚洲国产视频a| 免费成人结看片| 国产在线麻豆精品观看| av在线不卡电影| 91黄视频在线观看| 日韩亚洲欧美高清| 国产欧美日韩亚州综合 | 国产原创一区二区| 国产精品一区三区| 91女神在线视频| 欧美一区二区三区不卡| 国产欧美一区二区三区沐欲| 国产精品久久久久aaaa樱花| 亚洲高清视频的网址| 国产乱码精品1区2区3区| 9i看片成人免费高清| 91精品啪在线观看国产60岁| 久久精品视频在线看| 一区二区三区波多野结衣在线观看| 五月婷婷综合激情| 国产成人综合在线观看| 欧美婷婷六月丁香综合色| 精品美女被调教视频大全网站| 国产精品国产三级国产aⅴ原创| 亚洲3atv精品一区二区三区| 国产很黄免费观看久久| 欧美日韩亚洲综合在线| 欧美国产日本韩| 首页国产丝袜综合| 99热国产精品| 26uuu欧美| 五月天视频一区| aaa欧美色吧激情视频| 欧美一级夜夜爽| 一区二区三区四区高清精品免费观看 | 亚洲国产一区二区在线播放| 激情综合亚洲精品| 欧美主播一区二区三区| 久久免费看少妇高潮| 亚洲国产sm捆绑调教视频| 高清不卡一区二区在线| 在线不卡欧美精品一区二区三区| 国产精品不卡在线观看| 久久99国产精品久久99| 欧美视频日韩视频| 一级女性全黄久久生活片免费| 国产成人综合网| 欧美成人一级视频| 同产精品九九九| 色av成人天堂桃色av| 成人欧美一区二区三区在线播放| 精品一区二区三区视频| 日韩一区二区精品在线观看| 一区二区三区视频在线看| 成人国产精品免费观看| 久久久久久久久久久久久久久99 | 色综合久久中文综合久久97| 国产日韩欧美综合一区| 蜜桃视频在线观看一区| 欧美一区二区不卡视频| 亚洲一区二区三区四区不卡| 97精品久久久久中文字幕| 国产精品色在线| 99精品视频在线免费观看| 国产精品国产三级国产专播品爱网 | 精品制服美女久久| 日韩欧美久久久| 蜜臀久久99精品久久久久久9| 欧美高清一级片在线| 午夜伊人狠狠久久|