日期:2014-05-17 浏览次数:20685 次
import javax.swing.*;
ftpClient = new FtpClient();
ftpClient.openServer(server);
ftpClient.login(user, password);
ftpClient.binary();
TelnetInputStream is=ftpClient.get(filename);
JFileChooser jfc = new JFileChooser("d:\\");
int r = jfc.showSaveDialog(null);
File file = null;
if (r == JFileChooser.APPROVE_OPTION) {
file = jfc.getSelectedFile();
} else {
return;
}
//File file_out=new File("d:/1.doc");//输出文件名,要改为自定义,怎么改呢?
FileOutputStream os=new FileOutputStream(file_out);
byte[] bytes=new byte[1024];
int c;
while ((c=is.read(bytes))!=-1) {
os.write(bytes,0,c);
}
is.close();
os.close();
ftpClient.closeServer();