public void exportUrlsToFile(String file, String urls) throws IOException {
String[] urlsArray = urls.split("\\s+");// split on one or more white space characters.
// create a fresh file
RandomAccessFile raf = new RandomAccessFile(file, "rw");
for (String line : urlsArray) {
line = line.trim();
if (line.isEmpty()) {// this won't happen!
continue;
}
raf.writeBytes(line);
raf.writeBytes(newline);
}
// close the file handler
raf.close();
}
Basically I use this class to do something. This is part of application that is running inside tomcat JVM. I have noticed that anytime this method is called, it creates a file with the same name as the argument and after raf.close(), it is still there. How can I make sure that the temp file is removed.
Thanks in advance.