【发布时间】:2011-08-22 13:44:51
【问题描述】:
我将文件上传到服务器,但文件为空。(大小为零字节)
int reply;
ftp.connect(server,215);
ftp.login(username, Password);
System.out.println("Connected to " + server + ".");
System.out.print(ftp.getReplyString());
reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
}
System.out.println("FTP server connected.");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
InputStream input= new FileInputStream(source_file_path);
ftp.storeFile(dest_dir, input);
System.out.println(ftp.storeFile(dest_dir, input));
System.out.println( ftp.getReplyString() );
input.close();
ftp.logout();
【问题讨论】:
标签: java file-upload ftp