- 浏览: 146022 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
lyaqys:
lz实现的OptimisticExclusiveLock有点问 ...
java park/unpark 【java并发】基于JUC CAS原理,自己实现简单独占锁
private boolean wget(String file) {
// wget file
// targetDir must has been created, or cleared if necessary
DirUtils.mkDir(targetDir + "/" + UrlParser.getFilePath(file));
String orig_url = file;
String localFile = targetDir + "/" + file;
file = remoteServerConf.getProtocol() + "://" + file;
String cmd = "wget -t3 -T60 -c " + file + " -O " + localFile;
if (remoteServerConf.getProtocol().equalsIgnoreCase("ftp") == true
&& remoteServerConf.getFTPMode() == 0) {
cmd += " --no-passive-ftp";
}
if (remoteServerConf.getUser() != null && !remoteServerConf.getUser().isEmpty()) {
cmd += " --user " + remoteServerConf.getUser();
cmd += " --password " + remoteServerConf.getPassword();
}
String[] cmds = { "/bin/bash", "-c", cmd };
logger.info("start to exec \t" + cmd);
BufferedReader br = null;
int result = -1;
// 5850K .......... .......... .......... .......... .......... 97% 923K
// 0s
// 350K ,,,,,,, 100% 0.00 =0s
// 0K .......... .......... .......... .......... .......... 0% 309K 19s
// 50K .......... .......... .......... .......... .......... 1% 928K
// 13s
Matcher matcher = Pattern.compile("^\\s*(\\d+)K", Pattern.CASE_INSENSITIVE)
.matcher("");
try {
Runtime t = java.lang.Runtime.getRuntime();
Process p = t.exec(cmds);
br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
long prev_report_size = -(this.reportSizeInterval);
long curr_size = -(this.reportSizeInterval);
String msg = null;
while ((msg = br.readLine()) != null) {
// try to get download size
matcher.reset(msg);
if (matcher.find()) {
curr_size = Long.parseLong(matcher.group(1)) * 1024;
// System.out.println("curr_size: " + curr_size + "\t" +
// file);
if ((curr_size - prev_report_size) >= this.reportSizeInterval) {
updateDownloadSize(curr_size);
// logger.info("Has downloaded: " + curr_size + "\t" +
// file);
prev_report_size = curr_size;
}
}
// try to get length
// Length: 1181995 (1.1M)
// Length: 6213828 (5.9M), 4856852 (4.6M) remaining
// [application/octet-stream]
// Length: 366356 (358K)
// Length: 1181995 (1.1M), 1172559 (1.1M) remaining
else if (msg.startsWith("Length")) {
String[] fields = msg.split(" +");
if (fields.length > 1) {
this.length = Long.parseLong(fields[1]);
updateTotalLength(this.length);
logger.info("Total Length: " + length + "\t" + file);
}
}
}
br.close();
result = p.waitFor();
if (result == 0) {
if (uncompress(orig_url) != true)
{
logger.error("failed to uncompress the file" + orig_url);
}
else
return true;
}
} catch (IOException e) {
logger.error("IOException in wget " + file, e);
} catch (InterruptedException e) {
logger.error("InterruptedException in wget " + file, e);
} finally {
try {
br.close();
} catch (IOException e) {
logger.error("IOException in closing buffer reader " + file, e);
}
}
return result == 0 ? true : false;
}
// wget file
// targetDir must has been created, or cleared if necessary
DirUtils.mkDir(targetDir + "/" + UrlParser.getFilePath(file));
String orig_url = file;
String localFile = targetDir + "/" + file;
file = remoteServerConf.getProtocol() + "://" + file;
String cmd = "wget -t3 -T60 -c " + file + " -O " + localFile;
if (remoteServerConf.getProtocol().equalsIgnoreCase("ftp") == true
&& remoteServerConf.getFTPMode() == 0) {
cmd += " --no-passive-ftp";
}
if (remoteServerConf.getUser() != null && !remoteServerConf.getUser().isEmpty()) {
cmd += " --user " + remoteServerConf.getUser();
cmd += " --password " + remoteServerConf.getPassword();
}
String[] cmds = { "/bin/bash", "-c", cmd };
logger.info("start to exec \t" + cmd);
BufferedReader br = null;
int result = -1;
// 5850K .......... .......... .......... .......... .......... 97% 923K
// 0s
// 350K ,,,,,,, 100% 0.00 =0s
// 0K .......... .......... .......... .......... .......... 0% 309K 19s
// 50K .......... .......... .......... .......... .......... 1% 928K
// 13s
Matcher matcher = Pattern.compile("^\\s*(\\d+)K", Pattern.CASE_INSENSITIVE)
.matcher("");
try {
Runtime t = java.lang.Runtime.getRuntime();
Process p = t.exec(cmds);
br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
long prev_report_size = -(this.reportSizeInterval);
long curr_size = -(this.reportSizeInterval);
String msg = null;
while ((msg = br.readLine()) != null) {
// try to get download size
matcher.reset(msg);
if (matcher.find()) {
curr_size = Long.parseLong(matcher.group(1)) * 1024;
// System.out.println("curr_size: " + curr_size + "\t" +
// file);
if ((curr_size - prev_report_size) >= this.reportSizeInterval) {
updateDownloadSize(curr_size);
// logger.info("Has downloaded: " + curr_size + "\t" +
// file);
prev_report_size = curr_size;
}
}
// try to get length
// Length: 1181995 (1.1M)
// Length: 6213828 (5.9M), 4856852 (4.6M) remaining
// [application/octet-stream]
// Length: 366356 (358K)
// Length: 1181995 (1.1M), 1172559 (1.1M) remaining
else if (msg.startsWith("Length")) {
String[] fields = msg.split(" +");
if (fields.length > 1) {
this.length = Long.parseLong(fields[1]);
updateTotalLength(this.length);
logger.info("Total Length: " + length + "\t" + file);
}
}
}
br.close();
result = p.waitFor();
if (result == 0) {
if (uncompress(orig_url) != true)
{
logger.error("failed to uncompress the file" + orig_url);
}
else
return true;
}
} catch (IOException e) {
logger.error("IOException in wget " + file, e);
} catch (InterruptedException e) {
logger.error("InterruptedException in wget " + file, e);
} finally {
try {
br.close();
} catch (IOException e) {
logger.error("IOException in closing buffer reader " + file, e);
}
}
return result == 0 ? true : false;
}
发表评论
-
java 栈内存解惑
2013-10-23 23:41 638int j = 0; j = j++; ... -
简单的linux -c http-client
2013-10-23 15:35 4660#include<stdio.h> #includ ... -
linux进程cpu资源分配命令nice,renice,taskset
2013-09-04 14:03 1126nice,renice 指定进程运行的优先级 taskset ... -
c 专家编程
2013-08-13 17:06 652总结: -2> int * a = NUL ... -
Linux中线程与CPU核的绑定
2013-08-09 15:15 2083最近在对项目进行性能 ... -
建议编译的时候加警告 atof
2013-08-07 20:46 668#include <stdlib.h> ... -
feodra 17 安装 chrome
2013-08-04 01:35 7211: 下载:http://www.google.cn/chro ... -
Sudo提权出现:xx用户不在 sudoers 文件中
2013-08-03 20:22 870Sudo提权出现:xx用户不在 sudoers 文件中 症状 ... -
select,epoll,poll比较
2013-07-28 17:13 649select,poll,epoll简介 se ... -
gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数
2013-07-22 22:45 848我们用gcc编译程序时,可能会用到“-I”(大写i),“-L” ... -
Linux下如何将进程绑定在特定的CPU上运行
2013-07-22 10:52 947Linux下如何将进程绑定在特定的CPU上运行? 以root用 ... -
Google Guava Collections 使用介绍
2013-07-16 18:10 649Google Guava Collections 使用介绍 J ... -
Google Collections(Guava)中强大的Concurrent MapMaker
2013-07-16 18:07 1296仔细研究了刚发布1.0版本的Google Collection ... -
linux运维常用命令
2013-07-13 20:40 808推荐一个实用命令:awk '{x+=$2} END {prin ... -
linux 进程通信方式
2013-07-07 20:46 588# 管道( pipe ):管道是一种半双工的通信方式,数据只能 ... -
java wait 研究
2013-06-28 17:07 733[color=red]java wait 的使用必须放在实例对 ... -
java钩子函数的使用已经kill
2013-06-27 22:31 1511package com.aircoder.test; imp ... -
java获取所有的线程信息
2013-06-24 20:02 1564public class T2 { public sta ... -
判断两个一个链表是否存在循环(C专家编程中的问题)
2013-06-24 15:35 872判断两个一个链表是否存在循环(C专家编程中的问题) #incl ... -
java 获取mysql datetime 时间注意
2013-05-16 14:43 1475class SPubinfo implements RowMa ...
相关推荐
下载资源>把wget64.exe放置到C:\Windows\System32路径下>cmd 输入 wget64 下载链接地址
wget下载 VS2008 代码
wget-1.11.4-1源代码
wget是Linux中的一个下载文件的工具, wget是在Linux下开发的开放源代码的软件,作者是Hrvoje Niksic,后来被移植到包括Windows在内的各个平台上。 它用在命令行下。 对于Linux用户是必不可少的工具, 尤其对于网络...
相比较初代 GNU Wget,Wget2 速度更快,支持更多的协议,特别是围绕 HTTP/2 和压缩,支持多线程/并行连接,以及其他改进。 GNU Wget2 2.0 增加了 HTTP2 ...**在线文档** https://gnuwget.gitlab.io/wget2/reference/
wget命令行下载工具,支持在命令行下下载,等同于linux 下的wget命令。适合批处理下自动下载。
wget是一个从网络上自动下载文件的自由工具。它支持HTTP,HTTPS和FTP协议,可以使用HTTP代理. 所谓的自动下载是指,wget可以在用户退出系统的之后在后台执行。这意味这你可以登录系统,启动一个wget下载任务,然后...
这里有官方代码有关wget-1.5.3至wget-1.16的全部当前最新代码,只为拿来分享与大家学习共进步。
wget 下载工具 wget 下载工具 wget 下载工具 wget 下载工具
wget官方文档,搜索了好久才下到的,希望对各位有帮助, 内部包括 wget.chm wget.pdf wget.html等
网页下载工具,下载玩,解压缩直接使用就行了
在wget的源代码中 src/url.c 这个文件中有wget如何处理文件名的函数url_file_name() url_file_name()在根据url的形式判断该保存为什么样的文件名,并进行了多方面的考虑,最终该函数调用了append_uri_pathel(),该...
仅供学习使用
wget for ,通过CMD下载文件
Earthdata网站的TRMM数据wget工具下载详细方法,可以批量下载几万条数据,十分方便。
windows下的wget下载工具!它支持HTTP,HTTPS和FTP协议,可以使用HTTP代理. 所谓的自动下载是指,wget可以在用户退出系统的之后在后台执行。这意味这你可以登录系统,启动一个wget下载任务,然后退出系统,wget将在...
wget是一个从网络上自动下载文件的自由工具,支持通过HTTP、HTTPS、FTP三个最常见的TCP/IP协议下载,并可以使用HTTP代理。
wget 非常稳定 它在带宽很窄的情况下和不稳定网络中有很强的适应性 如果是由于网络的原因下载失败 wget命令会不断的尝试 直到整个文件下载完毕 如果是服务器打断下载过程 它会再次联到服务器上从停止的地方继续下载 ...
wget 命令行下载工具, 支持https win10亲测, 下载https文件: https_wget 链接
离线安装wget依赖包