
java使用ftp上传,文件上传不到指定目录
上传的文件都传到根目录了,就是不能传到指定目录。求助:是什么原因?主要代码:ftp.ftpPutFolder("E:\\dw1\\","/aaa/in");publicv...
上传的文件都传到根目录了,就是不能传到指定目录。求助:是什么原因?
主要代码:ftp.ftpPutFolder("E:\\dw1\\", "/aaa/in");
public void ftpPutFolderSan(String localPath, String remotePath)
throws Exception {
if (!isDirExist(client, remotePath)) {
client.makeDirectory(remotePath);
}
client.changeWorkingDirectory(remotePath);
File[] file = new File(localPath).listFiles();
for (int i = 0; file.length > i; i++) {
if (!file[i].isDirectory()) {
ftpPut(client, file[i].getAbsolutePath(), file[i].getName());
} else {
client.makeDirectory(file[i].getName());
ftpPutFolderSan(file[i].getAbsolutePath(), remotePath + "/"
+ file[i].getName());
}
}
client.changeToParentDirectory();
} 展开
主要代码:ftp.ftpPutFolder("E:\\dw1\\", "/aaa/in");
public void ftpPutFolderSan(String localPath, String remotePath)
throws Exception {
if (!isDirExist(client, remotePath)) {
client.makeDirectory(remotePath);
}
client.changeWorkingDirectory(remotePath);
File[] file = new File(localPath).listFiles();
for (int i = 0; file.length > i; i++) {
if (!file[i].isDirectory()) {
ftpPut(client, file[i].getAbsolutePath(), file[i].getName());
} else {
client.makeDirectory(file[i].getName());
ftpPutFolderSan(file[i].getAbsolutePath(), remotePath + "/"
+ file[i].getName());
}
}
client.changeToParentDirectory();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询