FTP 서버에 연결할 수 있습니다. 내 요구 사항은 서버에 로그인 한 후 표시 될 경로가 ftp 서버에서 쓰기 가능한지 확인하는 것입니다. 코드 아래 이FTP 서버에서 쓰기 가능한 파일을 확인하는 방법
public StringBuffer verifyMath(String host, String uname, String password, String cType){
String MathString = "FTPHost:[" + host + "];uname[" + uname + "];cType[" + cType + "]";
StringBuffer mBuffer = new StringBuffer();
FileInputStream fis = null;
FTPClient client = new FTPClient();
try {
client.connect(host);
boolean login = client.login(uname, password);
client.getReplyCode(); //230
if (login == true) {
log.debug("Connection established...");
String pwd = client.printWorkingDirectory();
File remotefile = new File(pwd);
boolean rmtfile = remotefile.canWrite();
boolean rmtdir = remotefile.isDirectory();
if(!(remotefile.isDirectory() && remotefile.canWrite())) {
mBuffer.append(MathLogger.raiseError(MathString, "Math is not Writable"));
}
boolean logout = client.logout();
if (logout) {
log.debug("Connection close...");
}
} else {
mBuffer.append(MathLogger.raiseError(MathString, "Connection failed."));
}
} catch (IOException e) {
mBuffer.append(MathLogger.raiseError(MathString, e));
} finally {
try {
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
return mBuffer;
}
시도 뭔가를 업로드하고 어떻게되는지 볼 수 있습니다. 읽기/쓰기 가능한 상태를 얻으려면 FTP 프로토콜을 지원하지 않습니다. 당신이 할 수있는 일은 그것이 성공/실패 여부를 시험 해보는 것입니다. –
이 제한됩니다. 파일이 ftp 서버에있을 때 다른 시스템에 문제를 일으키는 트리거가 있기 때문에 – mahesh
FTP 호스트에서 실행중인 일종의 웹 서비스를 작성하여 파일의 쓰기 상태를 반환 할 수 있습니까? MarcB가 말했듯이, 원시 FTP는 해당 정보를 전송하지 않습니다. – admdrew