簡(jiǎn)單+勤奮

          保持輕松和清醒,你就無(wú)往而不勝

            BlogJava :: 首頁(yè) :: 聯(lián)系 :: 聚合  :: 管理
            1 Posts :: 1 Stories :: 0 Comments :: 0 Trackbacks

          2009年1月3日 #

          根據(jù)指定URL下載一個(gè)網(wǎng)頁(yè)的內(nèi)容

          //import java.net.*
          def url= new URL("http://book.qq.com/s/book/0/15/15722/2.shtml");
          URLConnection connection
          =url.openConnection();
          InputStream ips
          =connection.getInputStream();
          String filename
          =url.getFile();
          println(filename)
          FileOutputStream fos
          =new FileOutputStream("D:\\07_his\\test.txt");
          String line
          =System.getProperty("line.separator");
          println 
          "主機(jī)名:"+url.getHost()
          println 
          "授權(quán)::"+url.getAuthority()
          println 
          "文件名:"+url.getFile()
          println 
          "端口號(hào):"+url.getDefaultPort()
          println 
          "Type: "+connection.getContentType()
          println 
          "長(zhǎng)度:"+connection.getContentLength()
           def data;
           
          while((data=ips.read())!=-1)
           
          {
            fos.write(data);
           }

           ips.close();
           fos.close();
                                  

           

           

          posted @ 2009-01-03 22:12 圣潔王子 閱讀(377) | 評(píng)論 (0)編輯 收藏

          主站蜘蛛池模板: 平安县| 吉林省| 阳春市| 闻喜县| 海原县| 德钦县| 高碑店市| 澄江县| 霍城县| 福鼎市| 石门县| 咸阳市| 新龙县| 镇江市| 五大连池市| 宝鸡市| 特克斯县| 琼海市| 大余县| 蚌埠市| 东山县| 民和| 宾川县| 岳阳市| 安达市| 丹凤县| 云和县| 临夏县| 保康县| 太原市| 中方县| 修水县| 长治县| 武宁县| 双柏县| 南昌市| 靖边县| SHOW| 康保县| 本溪市| 淮滨县|