I have the following situation, I want to upload a temporary file to an FTP server, I have the following code:
public static void uploadFileFtp(String file,FTPClient client,String name) throws IOException {
File files = File.createTempFile(name, ".txt");
String[] lines = file.split("\n");
int length = lines.length;
BufferedWriter bw = new BufferedWriter(new FileWriter(files));
for(int i=0;i<length;i++) {
bw.write(lines[i]);
}
bw.close();
InputStream stream = new FileInputStream(files.getName());
boolean upload = client.storeFile(files.getName(), stream);
if(upload)
System.out.println("Hecho, numero de saltos de linea : "+length);
}
File is a string that I want to write in my temporary file (which it already does), then I try to get the name of that file and upload it to my ftp, but I get the following exception:
java.io.FileNotFoundException: 103279143710072458372941584.txt (El sistema no puede encontrar el archivo especificado)
They could help me know how I can get the route where the storm is stored and can get that file.
Edit 1 I could find the file, I had to find it in the following way:
InputStream stream = new FileInputStream(files.getAbsolutePath());
Now my next question, is there any way I can change the name of that temporary file?
Thank you.