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

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

?? streamtests.java

?? html解析包 可以很方便的解析html 純java 實現
?? JAVA
字號:
// HTMLParser Library $Name: v1_6_20051112 $ - 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: 2004/01/14 02:53:47 $// $Revision: 1.16 $//// 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;        // pick a big file        link = "http://htmlparser.sourceforge.net/HTMLParser_Coverage.html";        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一区二区三区免费野_久草精品视频
欧美精品一区二区久久婷婷| 视频一区欧美精品| 亚洲午夜影视影院在线观看| 久久丁香综合五月国产三级网站| av一二三不卡影片| 欧美一卡二卡在线| 亚洲日本在线看| 成人h动漫精品| 精品成人一区二区三区四区| 亚洲国产婷婷综合在线精品| 波多野结衣视频一区| 久久综合色婷婷| 日韩精品欧美精品| 欧美性一区二区| 综合久久久久综合| 丁香激情综合国产| 精品国产成人系列| 精品综合免费视频观看| 337p亚洲精品色噜噜| 亚洲一区二区三区美女| 91麻豆国产福利在线观看| 国产亚洲婷婷免费| 国产精品一区二区91| 精品日韩一区二区三区 | 成人激情开心网| 国产喂奶挤奶一区二区三区| 狠狠久久亚洲欧美| 26uuu亚洲| 国产一区999| 国产欧美1区2区3区| 国产盗摄精品一区二区三区在线| 精品久久99ma| 国内精品国产成人| 亚洲精品在线观看网站| 国内外成人在线视频| 久久综合九色综合欧美亚洲| 国产一区二区三区免费播放| 欧美r级在线观看| 国产一区欧美日韩| 国产精品日韩精品欧美在线| eeuss鲁一区二区三区| 国产精品日韩成人| 色婷婷综合中文久久一本| 亚洲精品伦理在线| 欧美无砖专区一中文字| 亚洲va天堂va国产va久| 欧美一级欧美一级在线播放| 久久精品国产99国产精品| 久久综合色综合88| 99热这里都是精品| 亚洲一区在线观看网站| 欧美猛男gaygay网站| 久久99久久99小草精品免视看| 日韩亚洲欧美成人一区| 国产乱码精品一区二区三区忘忧草 | 国产精品全国免费观看高清 | 欧美日本一区二区| 日本 国产 欧美色综合| 久久综合色一综合色88| 国产盗摄一区二区| 一区二区激情小说| 欧美一卡2卡三卡4卡5免费| 国产一区二区福利| 亚洲女子a中天字幕| 69堂国产成人免费视频| 国产一区二区三区四| 一区二区三区四区不卡在线| 日韩午夜在线观看视频| 成人黄色一级视频| 日韩激情一区二区| 国产精品理论片| 欧美一区二区三区四区久久| 国产91在线观看丝袜| 亚洲一线二线三线久久久| 欧美大片一区二区三区| 91麻豆自制传媒国产之光| 免费在线观看视频一区| 国产精品理论在线观看| 欧美精选在线播放| 成人动漫一区二区三区| 麻豆精品一区二区三区| 夜夜精品视频一区二区 | 亚洲色欲色欲www在线观看| 欧美一区二区黄| 91蜜桃婷婷狠狠久久综合9色| 美女爽到高潮91| 亚洲综合999| 国产精品免费久久久久| 欧美大肚乱孕交hd孕妇| 在线精品视频一区二区三四| 国产91在线观看丝袜| 麻豆精品一区二区综合av| 亚洲曰韩产成在线| 国产精品麻豆网站| 久久久久久久久久久99999| 欧美日高清视频| 欧美中文字幕一区二区三区亚洲| 成人黄动漫网站免费app| 蜜桃精品在线观看| 视频一区欧美精品| 亚洲一区二区三区四区在线| 国产精品视频一二| 久久综合久久综合久久综合| 欧美一区二区三区视频| 欧美放荡的少妇| 欧美日韩精品一二三区| 欧美性一级生活| 欧美羞羞免费网站| 欧美日韩一区三区| 欧美性感一区二区三区| 欧美在线free| 欧美午夜精品免费| 欧美伊人久久久久久午夜久久久久| 97久久精品人人澡人人爽| 丁香激情综合五月| 成人短视频下载| 99re在线精品| 在线中文字幕一区| 色婷婷av一区二区三区gif | 黄色精品一二区| 麻豆91在线观看| 经典三级视频一区| 国产在线看一区| 成人免费毛片高清视频| av不卡在线播放| 日本乱人伦aⅴ精品| 91国偷自产一区二区开放时间| 色婷婷av一区二区| 在线成人av影院| 欧美成人一区二区三区片免费| 欧美精品一区二区在线观看| 久久久五月婷婷| 中文字幕一区日韩精品欧美| 亚洲伦理在线精品| 五月综合激情婷婷六月色窝| 99视频一区二区| 91免费国产在线观看| 欧美精品三级在线观看| 精品精品国产高清a毛片牛牛| 久久久99久久| 伊人色综合久久天天人手人婷| 亚洲高清久久久| 国产在线视视频有精品| 北岛玲一区二区三区四区| 色哟哟一区二区三区| 制服丝袜av成人在线看| 久久毛片高清国产| 亚洲综合色区另类av| 蜜臀精品一区二区三区在线观看| 国产一区二区在线影院| 色吧成人激情小说| 精品精品国产高清a毛片牛牛| 中文字幕日韩一区| 久久精品噜噜噜成人av农村| 波多野结衣中文字幕一区二区三区 | 久久久久久久久久久电影| 亚洲精品成人在线| 蜜桃视频在线观看一区| 99精品桃花视频在线观看| 欧美一区欧美二区| 日韩伦理电影网| 精品一区二区免费视频| 一本到一区二区三区| 精品三级在线看| 亚洲高清一区二区三区| 成人午夜在线视频| 日韩欧美国产综合在线一区二区三区 | 欧美福利视频一区| 国产精品美女www爽爽爽| 青草av.久久免费一区| 91视频一区二区| 久久久亚洲欧洲日产国码αv| 五月天精品一区二区三区| 99国产精品久久久久久久久久| 精品日韩欧美在线| 亚洲va国产天堂va久久en| 国产成人av电影在线| 中文字幕一区二区三| 精品一区二区三区在线播放视频| 欧美在线视频全部完| 国产精品美女www爽爽爽| 国产一区二区在线影院| 日韩视频一区二区三区| 午夜欧美2019年伦理| 色婷婷综合五月| 亚洲免费av观看| 99视频精品免费视频| 国产精品免费视频一区| 国产乱国产乱300精品| 日韩欧美国产一二三区| 日韩av一区二区三区四区| 色婷婷综合久色| 亚洲欧美日韩在线播放| 91在线精品一区二区三区| 国产日韩精品一区| 成人午夜精品在线| 国产精品美女一区二区三区| 大尺度一区二区| 中文字幕精品一区| 岛国精品一区二区|