我正在开发一个小程序,它可以将文件上传到我的FTP服务器并用它做一些其他的事情.现在......一切正常,我正在使用org.apache.commons.net.ftp FTPClient
该类进行上传.
ftp = new FTPClient();
ftp.connect(hostname);
ftp.login(username, password);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.changeWorkingDirectory("/shares/public");
int reply = ftp.getReplyCode();
if (FTPReply.isPositiveCompletion(reply)) {
addLog("Uploading...");
} else {
addLog("Failed connection to the server!");
}
File f1 = new File(location);
in = new FileInputStream(
ftp.storeFile(jTextField1.getText(), in);
addLog("Done");
ftp.logout();
ftp.disconnect();
Run Code Online (Sandbox Code Playgroud)
应上传的文件在hTextField1中命名.现在......我如何添加进度条?我的意思是,ftp.storeFile中没有流...我该如何处理?
谢谢你的帮助!:)
问候