<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-295  評論-26  文章-1  trackbacks-0

    import java.io.*;
    import java.net.*;
    public class Test {
    ??? public boolean saveUrlAs(String photoUrl, String fileName) {
    ??????? //此方法只能用于HTTP協議
    ??????? try {
    ??????????? URL url = new URL(photoUrl);
    ??????????? HttpURLConnection connection = (HttpURLConnection) url.
    ??????????????????? openConnection();
    ??????????? DataInputStream in = new DataInputStream(connection.getInputStream());
    ??????????? DataOutputStream out = new DataOutputStream(new FileOutputStream(fileName));
    ??????????? byte[] buffer = new byte[4096];
    ??????????? int count = 0;
    ??????????? while ((count = in.read(buffer)) > 0) {
    ??????????????? out.write(buffer, 0, count);
    ??????????? }
    ??????????? out.close();
    ??????????? in.close();
    ??????????? return true;
    ??????? } catch (Exception e) {
    ??????????? return false;
    ??????? }
    ??? }
    ???
    ??? public String getDocumentAt(String urlString) {
    ??????? //此方法兼容HTTP和FTP協議
    ??????? StringBuffer document = new StringBuffer();
    ??????? try {
    ??????????? URL url = new URL(urlString);
    ??????????? URLConnection conn = url.openConnection();
    ??????????? BufferedReader reader = new BufferedReader(new InputStreamReader(
    ??????????????????? conn.getInputStream()));
    ??????????? String line = null;
    ??????????? while ((line = reader.readLine()) != null) {
    ??????????????? document.append(line + "\n");
    ??????????? }
    ??????????? reader.close();
    ??????? }catch (MalformedURLException e) {
    ??????????? System.out.println("Unable to connect to URL: " + urlString);
    ??????? }catch (IOException e) {
    ??????????? System.out.println("IOException when connecting to URL: " +
    ??????????????????? urlString);
    ??????? }
    ??????? return document.toString();
    ??? }
    ???
    ??? public static void main(String[] args) throws IOException {
    ??????? Test test = new Test();
    ??????? String photoUrl = "??????? String fileName = photoUrl.substring(photoUrl.lastIndexOf("/"));
    ??????? String filePath = "c:";
    ??????? boolean flag = test.saveUrlAs(photoUrl, filePath + fileName);
    ??????? System.out.println("Run ok!\nGet URL file " + flag);
    ??? }
    }


    ?



    大盤預測 國富論
    posted on 2007-08-21 11:30 華夢行 閱讀(916) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲午夜国产精品| 最近新韩国日本免费观看 | 成人电影在线免费观看| 日本免费精品一区二区三区| 美国毛片亚洲社区在线观看 | 黄网址在线永久免费观看 | 日本黄页网址在线看免费不卡| 亚洲精品在线不卡| 亚洲jjzzjjzz在线播放| 亚洲毛片一级带毛片基地| 亚洲成a人片在线网站| 国产亚洲精品成人AA片| WWW国产亚洲精品久久麻豆| 黄色视屏在线免费播放| 性xxxx视频播放免费| 久久亚洲成a人片| 美女裸免费观看网站| 毛片免费全部播放无码| 亚洲一区二区高清| 四虎永久免费地址在线观看| 日韩精品亚洲人成在线观看| 美女视频黄a视频全免费网站色| 亚洲成人在线免费观看| 国产精品亚洲视频| 国产亚洲日韩在线a不卡| 黄在线观看www免费看| 亚洲国产综合专区电影在线| 美女视频黄a视频全免费网站色| 在线A级毛片无码免费真人| 亚洲电影免费观看| 亚洲精品国产免费| 亚洲第一区视频在线观看| 久久精品成人免费看| 337p日本欧洲亚洲大胆裸体艺术| 亚洲6080yy久久无码产自国产 | 久久国产精品成人片免费| 亚洲国产精品乱码一区二区 | 免费一区二区三区在线视频| 国产午夜免费福利红片| 美女被免费网站在线视频免费| 国产又大又粗又硬又长免费|