fix:修改ftp切换的目录
This commit is contained in:
parent
ebdf8d863a
commit
f4b05e2da1
|
@ -74,6 +74,27 @@ public class FTPUtil {
|
||||||
return this.ftpRootPath;
|
return this.ftpRootPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
try {
|
||||||
|
FTPClient ftp = new FTPClient();
|
||||||
|
//连接
|
||||||
|
ftp.connect("172.21.170.122", 21);
|
||||||
|
//登录
|
||||||
|
ftp.login("rmsops", "cnndc010");
|
||||||
|
// 切换为本地被动模式,可以解决FTP上传后文件为空的问题,但需要服务器将FTP服务添加至防火墙白名单
|
||||||
|
ftp.enterLocalPassiveMode();
|
||||||
|
//切换工作路径
|
||||||
|
ftp.changeWorkingDirectory("/SpectrumFile/admin");
|
||||||
|
//判断是否连接成功
|
||||||
|
int reply = ftp.getReplyCode();
|
||||||
|
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||||
|
ftp.disconnect();
|
||||||
|
System.out.printf(reply+"");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 登录ftp
|
* 登录ftp
|
||||||
* @return
|
* @return
|
||||||
|
@ -89,7 +110,7 @@ public class FTPUtil {
|
||||||
// 切换为本地被动模式,可以解决FTP上传后文件为空的问题,但需要服务器将FTP服务添加至防火墙白名单
|
// 切换为本地被动模式,可以解决FTP上传后文件为空的问题,但需要服务器将FTP服务添加至防火墙白名单
|
||||||
ftp.enterLocalPassiveMode();
|
ftp.enterLocalPassiveMode();
|
||||||
//切换工作路径
|
//切换工作路径
|
||||||
ftp.changeWorkingDirectory(ftpRootPath);
|
ftp.changeWorkingDirectory("/");
|
||||||
//判断是否连接成功
|
//判断是否连接成功
|
||||||
int reply = ftp.getReplyCode();
|
int reply = ftp.getReplyCode();
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user