我用FtpClient批量下载文件运行到new BufferedInputStream(client.get(s),10000)时经常就不能继续运行,请问怎么解决
解决方案 »
- jfreechart中柱状图上面如何显示数值?
- jtable里的数据可以作为一个整体保存在数据库中吗
- 急问!?
- 求聊天室Demo
- 这个数据库如何设计
- 打印置换字符串的问题
- it公司常见java面试题汇总
- martin的<<uml for java programmer>> 远程编译 smc 文件的例子谁编译过没有?
- 急!!!帮忙看看代码有什么错啊?(socket的)
- 谁能提供一些 Java 平台用于小型网络设备的平台的资料?
- 编译出现unchecked call to add(E)的警告问题怎么解决?高手快进来,非常感谢!
- 用Integer.parseInt()转换字符时抛出NumberFormatException异常,把字符改短一点又没事
DataInputStream dis=null;
BufferedInputStream inFile=null;
BufferedOutputStream outFile=null;
try {
dis = new DataInputStream(client.list());
int readCount;
String s="";
while((s=dis.readLine())!=null){
String[] a=s.split(" ");
s=new String(a[a.length-1].getBytes("iso8859-1"),"GBK");
System.out.println("Getting:"+s);
fileNames.add(s);
File file=new File(savePath);
if(!file.exists()){
FileOption.createFolder(file);
}
inFile=new BufferedInputStream(client.get(s),10000);
System.out.println("stop"+s);////////////////
outFile=new BufferedOutputStream(
new FileOutputStream(new File(savePath+s))); byte[]buffer=new byte[1024];
while((readCount =inFile.read(buffer))!=-1) {
byte[]t=new byte[readCount];
System.arraycopy(buffer,0,t,0,readCount);
outFile.write(t);
outFile.flush();
}
}
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
if(dis!=null){
try {
dis.close();
dis=null;
} catch (IOException e) {
}
}
if(inFile!=null){
try {
inFile.close();
inFile=null;
} catch (IOException e) {
}
}
if(outFile!=null){
try {
outFile.close();
outFile=null;
} catch (IOException e) {
}
}
}
}
这是下载的完整代码