0
FTPサーバーにディレクトリを作成し、そのディレクトリにファイルをアップロードしようとしています。あなたは、私が作成したディレクトリに書き込み権限を設定することで私を助けてもらえjava ftpのsetPermission
LOGGED IN SERVER
257
created
Start uploading first file
The first file is uploaded successfully.
:ディレクトリ正常に作成されますが、ファイルがアップロードされていないが、私は次の応答を取得しています許可
FTPClient ftpClient = new FTPClient();
public void ftpConnection(){
try {
ftpClient.connect(server,port);
ftpClient.enterLocalPassiveMode();
int replyCode = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(replyCode)) {
System.out.println("Operation failed. Server reply code: " + replyCode);
}
boolean success = ftpClient.login(user, pass);
if (!success) {
System.out.println("Could not login to the server");
} else {
System.out.println("LOGGED IN SERVER");
boolean created = ftpClient.makeDirectory("/usr/prtsim");
int returnCode = ftpClient.getReplyCode();
System.out.println(returnCode);
if(created){
System.out.println("created");
ftpClient.changeWorkingDirectory("/usr/prtsim");
uploadFile();
}
else{
if (returnCode == 550)
System.out.println("Directory already present");
else
System.out.println("not created");
}
ftpClient.logout();
ftpClient.disconnect();
}
}
catch(IOException ex) {
System.out.println("Oops! Something wrong happened");
ex.printStackTrace();
}
}
public void uploadFile() throws FileNotFoundException, IOException{
File firstLocalFile = new File("C:\\Users\\sswaroo\\Desktop\\sampletext.txt");
//ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
String firstRemoteFile = "sampletext.txt";
InputStream inputStream = new FileInputStream(firstLocalFile);
System.out.println("Start uploading first file");
boolean done = ftpClient.storeFile(firstRemoteFile, inputStream);
inputStream.close();
if (done) {
System.out.println("The first file is uploaded successfully.");
}
}
}
を書くことが原因である可能性があり?