我需要更改要上传文件的 Java 程序中的工作目录,但我无法更改工作目录。目前我正在使用以下代码,请看看这里出了什么问题。
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.commons.net.ftp.FTPClient;
public class FileUploadDemo {
public static void main(String[] args) {
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("36.109.60.40");
client.login("XYZ", "SYSTEM");
client.enterLocalPassiveMode();
boolean changeWorkingDirectory = client.changeWorkingDirectory("ABC\\QSRC");
if (changeWorkingDirectory)//this is false here
{
String filename = "ATR.CBL";
fis = new FileInputStream("C:\\Users\\RATSYA\\Desktop\\backup\\DINAKE\\ATR.CBL");
boolean storeFile = client.storeFile(filename, fis);
if(storeFile)
System.out.println("file stored");
else
System.out.println("file can not be stored");
client.logout();
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}