0
をダウンロードしていない私はFTPClientを使用して、サーバーからzipファイルをダウンロードしようとしていたダウンロードのための私のコードはJavaのFTPクライアントは、ファイル
FTPClient ftpClient = new FTPConnection().makeConnection(loc);
try {
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
success = ftpClient.changeWorkingDirectory(PATH + preset + "/" + file_to_download + offset);
System.out.println("Download Path:-" + PATH + preset + "/" + file_to_download + offset);
if (!success) {
System.out.println("Could not changed the directory to RIBS");
return;
} else {
System.out.println("Directory changed to RIBS");
}
FTPFile[] files = ftpClient.listFiles();
for (FTPFile file : files) {
if (file.getName().contains(".zip")) {
dfile = file;
}
}
fsize=dfile.getSize();
fileMap.put("build", dfile.getName());
primaryStage = (Stage) ap.getScene().getWindow();
String homePath = System.getProperty("user.home");
File downloadPath = new File(homePath + "\\Buildss\\" + osVer);
if (!downloadPath.exists()) {
if (downloadPath.mkdirs()) {
System.out.println("Directory is created!");
} else {
System.out.println("Failed to create directory!");
}
}
// System.out.println(chosenDir.getAbsolutePath());
filePath = new File(downloadPath + "/" + dfile.getName());
if (filePath.exists()) {
System.out.println("File altready exist");
return;
}
else {
fileMap.put("path", filePath.toString());
fileMap.put("kind", "RIBS");
Task downloadTask = new Task<Void>() {
@Override
public Void call() throws IOException {
try {
long len = dfile.getSize();
System.out.println("File From Server:::::: " + len);
downloadFile = new File(downloadPath + "/" + dfile);
outputFile = new FileOutputStream(downloadFile);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ftpClient.sendNoOp();
ftpClient.setConnectTimeout(1000);
//ftpClient.retrieveFile(dfile, output);
if (ftpClient.retrieveFile(dfile.getName(), outputFile) == true) {
downloadButton.setDisable(true);
System.out.println("LOCAL FILE LENGTH:-" + downloadFile.length());
}
return null;
}
};
Thread t = new Thread(downloadTask);
t.start();
ですが、私はダウンロード場所を行けば今、私はこの「-rwxrwxような何かを参照してください--- 1 ftp ftp 513235293 Apr 11 06 "ファイルはダウンロードされていません。 このコードは働いていました。
'retrieveFile()'呼び出しの後、 'getReplyCode()'を呼び出して、最後のFTP応答の返信コードをチェックすることができます。それはあなたに多くの情報を与えるでしょう。 –
返信コードは226です。「データ接続に影響を与える以前のクライアントコマンドを正常に処理した後に、データ接続を閉じる前に226返信コードがサーバーから送信されます」ほとんどの場合、ファイル転送の完了を通知します。 " – user3649361
Can出力(sys out)文も追加しますか?私はsysoutの 'downloadFile'オブジェクトも書いています。 –