LGA*_*GAP 2 java ftp zip corrupt
我的java程序将zip文件从我的系统上传到FTP服务器.uploadfile()是一个包含上传代码的函数.
uploadfile( "192.168.0.210", "muruganp", "vm4snk", "/首页/管理/ GATE521/LN_RB_Semivalid2junk /输出/" +日期+ "_ RB1.zip", "/文件服务器/ filesbackup/EMAC /" +日期+"_ RB1 .压缩");
public static boolean uploadfile(String server, String username,
String Password, String source_file_path, String dest_dir) {
FTPClient ftp = new FTPClient();
try {
int reply;
ftp.connect(server);
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.");
return false;
}
System.out.println("FTP server connected.");
InputStream input = new FileInputStream(source_file_path);
ftp.storeFile(dest_dir, input);
System.out.println(ftp.getReplyString());
input.close();
ftp.logout();
} catch (Exception e) {
System.out.println("err");
e.printStackTrace();
return false;
} finally {
if (ftp.isConnected()) {
try {
ftp.disconnect();
} catch (Exception ioe) {}
}
}
return true;
}
Run Code Online (Sandbox Code Playgroud)
我在我的系统中拥有的zip文件非常完美.但在服务器位置上传相同内容后,下载相同,并解决问题."文件已损坏"说错误.我该怎么做才能解决这个问题.请就此提出建议.
我怀疑问题会是这样,通过ASCII模式传输.它应该按照本问题实际通过二进制模式传输.如何达到同样的目标?请指教.
| 归档时间: |
|
| 查看次数: |
3706 次 |
| 最近记录: |