wget下载

wget命令

e:\wget  -r -c  --limit-rate=1M -t 10  -T 60  -o d:\wgetlog\result.txt -O E:\projectTest/rhq-agent-update.log http://xxxx:8280/../opt/app/install/rhq-agent-update.log

程序关键代码

String cmd = wgetPath+"\\wget  -r -c  --limit-rate=1M -t 10  -T "+timeoutms+"  -o " + logPath + " -O " + filePath + " " + url;
Process download=Runtime.getRuntime().exec(cmd);
download.waitFor();
new Thread () {
    public void run() {
        logger.info("start resultFile monitor!");
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e)  {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            BufferedReader reader = null;;
            try {
                reader = new BufferedReader(new FileReader(logFile));
                while(true) {
                    String line = reader.readLine();
                    if (line != null) {
                        logger.debug(line);
                    } else {
                        break;
                    }
                }
                break;
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } finally {
                try {
                    if (reader != null)
                        reader.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }
        validateFile();
    }


    public void validateFile() {
        File download = new File(filePath);
        try {
            if(download.length() > 0) {
                DownloadXMLConfig.setFileStatus(verNum,fileName, "download");
            }else{
                DownloadXMLConfig.setFileStatus(verNum,fileName, "fail");
                if (download.exists()) {
                     download.delete();
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
            logger.error("DownloadXMLConfig setFileStatus exception : "+e);
        }
    }
}.start();


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值