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

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

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

    夢幻之旅

    DEBUG - 天道酬勤

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
    JAVA代碼:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;

    public class W
    {
        
    public static void main(String[] args)
        
    {
            
    /*
             * String[] paras = new String[]
             * {"
    http://m.weather.com.cn/data/101020100.html", "g:/abc.txt" };
             
    */

            
    new W().working(args);
        }

        
        
    /**
         * <ul>
         * <li>Description:[總調用程序]</li>
         * <li>Created by [Huyvanpull] [2013-3-14]</li>
         * <li>Midified by [modifier] [modified time]</li>
         * </ul>
         * 
         * 
    @param paras
         
    */

        
    public void working(String[] paras)
        
    {
            StringBuffer result 
    = new StringBuffer();
            
    if (paras != null && paras.length == 2)
            
    {
                result.append(paras[
    0]).append(",");
                result.append(getDateStr()).append(
    ",");
                
                String tempStr 
    = "";
                
    try
                
    {
                    tempStr 
    = this.sendUrl(paras[0]);
                }

                
    catch (Exception ex)
                
    {
                    ex.printStackTrace();
                }

                result.append(tempStr);
            }

            
    else
            
    {
                result.append(
    "參數不正確");
            }

            result.append(System.getProperty(
    "line.separator"));
            System.out.println(result);
            writeFile(paras[
    1], result.toString());
        }

        
        
    /**
         * <ul>
         * <li>Description:[根據網址得到內容]</li>
         * <li>Created by [Huyvanpull] [2013-3-14]</li>
         * <li>Midified by [modifier] [modified time]</li>
         * </ul>
         * 
         * 
    @param urlStr
         * 
    @return
         
    */

        
    public String sendUrl(String urlStr)
        
    {
            BufferedReader in 
    = null;
            StringBuffer temp 
    = new StringBuffer();
            
    try
            
    {
                URL yahoo 
    = new URL(urlStr);
                in 
    = new BufferedReader(new InputStreamReader(yahoo.openStream(),
                        
    "UTF-8"));
                String inputLine;
                
    while ((inputLine = in.readLine()) != null)
                    temp.append(inputLine);
            }

            
    catch (Exception ex)
            
    {
                ex.printStackTrace();
            }

            
    finally
            
    {
                
    if (in != null)
                
    {
                    
    try
                    
    {
                        in.close();
                    }

                    
    catch (Exception ex)
                    
    {
                        ex.printStackTrace();
                    }

                }

            }

            
    return temp.toString();
        }

        
        
    /**
         * <ul>
         * <li>Description:[寫字符串到文件]</li>
         * <li>Created by [Huyvanpull] [2013-3-14]</li>
         * <li>Midified by [modifier] [modified time]</li>
         * </ul>
         * 
         * 
    @param filePath
         * 
    @param content
         
    */

        
    public static void writeFile(String filePath, String content)
        
    {
            FileWriter fw 
    = null;
            
    try
            
    {
                File file 
    = new File(filePath);
                fw 
    = new FileWriter(file, true);
                fw.write(content);
            }

            
    catch (Exception ex)
            
    {
                ex.printStackTrace();
            }

            
    finally
            
    {
                
    try
                
    {
                    
    if (fw != null)
                    
    {
                        fw.close();
                    }

                }

                
    catch (Exception ex)
                
    {
                    ex.printStackTrace();
                }

            }

        }

        
        
    public String getDateStr()
        
    {
            SimpleDateFormat simpleDateFormate 
    = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            
    return simpleDateFormate.format(Calendar.getInstance().getTime());
        }

        
    }



    調用代碼:
    java -jar f:/w.jar http://m.weather.com.cn/data/101020100.html f:/kkk.txt
    posted on 2013-03-15 10:15 HUIKK 閱讀(545) 評論(0)  編輯  收藏 所屬分類: Java
    主站蜘蛛池模板: 免费在线视频你懂的| 亚洲mv国产精品mv日本mv| 狠狠色婷婷狠狠狠亚洲综合 | 亚洲91精品麻豆国产系列在线| 亚洲国产综合91精品麻豆| 久久久久亚洲精品无码系列| 久久国产精品亚洲综合| 内射干少妇亚洲69XXX| 亚洲色欲或者高潮影院| 亚洲欧洲国产经精品香蕉网| 亚洲午夜电影在线观看| 亚洲中文精品久久久久久不卡| 中文字幕无码亚洲欧洲日韩| 亚洲国产精品无码中文lv| 国产成人亚洲午夜电影| 五月天婷婷免费视频| 中文字幕av无码不卡免费| 久久久久国色av免费看| 国产精品成人免费福利| 妞干网免费视频在线观看| 免费h黄肉动漫在线观看| 精品国产亚洲男女在线线电影 | 亚洲理论片中文字幕电影| 亚洲一区二区久久| 亚洲欧美日韩久久精品| 青娱乐在线视频免费观看| 精品国产免费人成网站| 999任你躁在线精品免费不卡| 114一级毛片免费| 国产又黄又爽又猛的免费视频播放 | 18禁超污无遮挡无码免费网站| 99re在线视频免费观看| 国产三级在线观看免费| 免费人成网站在线高清| 亚洲高清国产AV拍精品青青草原| 亚洲麻豆精品果冻传媒| 亚洲精品国产第一综合99久久| 九九热久久免费视频| 亚洲精品在线免费观看| 国产免费久久精品久久久| 国产av无码专区亚洲av桃花庵|