url与ftpclient比较

来源:互联网 发布:网络交易中间商 模式 编辑:程序博客网 时间:2024/06/06 20:50

1、url比较适合网页http下载
ftp显得力不从心,如:(只能是指定读取到的目录下的文件,不能对其他目录下的文件操作)
URL url = new URL("ftp://tnms:tnms@136.96.50.41:21/TNMS300_GENERALALARM_20110302/currentalarm2011-04-14 10:36:07.txt");
System.out.println(url.getPath());
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"utf-8"));
PrintWriter out = new PrintWriter("d:/hello222.txt");
String lineString = "";
do{
 lineString = in.readLine();
 out.println(lineString);
 out.flush();
} while (lineString != null);
System.out.println(URLEncoder.encode("@"));//特殊字符的转码

2、ftpclient弥补了上面的不足,并且还有很多别的功能