i have ftp server and on him i have 2 folders - 1st is called pages, which is empty and the other is template, where is the file index.php. I want that file to be copy and paste into the folder "pages" and rename it of course. I saw example with ftp.rename() and the result was, i just moved the file from one folder to the other. When i execute that code i get this error:
Caused by: java.io.FileNotFoundException: \template\index.php (The system cannot find the path specified)
The file exist suck as the folder. What i should change in the code. Thanks !
private void generateHTMLPHPfiles() throws IOException{
String ftpURL="111.111.111.1";
int port=11;
String usern="FTP";
String passw="pass";
FTPClient ftp=new FTPClient();
String templ="/template/index.php";
FileInputStream fis1= new FileInputStream(new File(templ));
try {
ftp.connect(ftpURL,port);
ftp.login(usern, passw);
ftp.enterLocalActiveMode();
ftp.setFileType(FTP.BINARY_FILE_TYPE);
JOptionPane.showMessageDialog(null, "Започва качването на файла....");
boolean changedir=ftp.changeWorkingDirectory("/pages");
boolean donehtml=ftp.storeFile("proba.php", fis1);
// fis1.close();
if (donehtml ) {
System.err.println("Its good!!");
}
} catch (IOException ex) {
System.out.println("Error: " + ex.getMessage());
ex.printStackTrace();
}
finally{
try {
if (ftp.isConnected()) {
ftp.logout();
ftp.disconnect();
}
}
catch(IOException ex1){
ex1.printStackTrace();
}
}
}