The javadoc for renameTo()
says:
The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists.
Try closing all the files (you are not closing reader
so it is still "in use") and deleting first the input file:
} finally {
try {
inputFile.delete();
reader.close();
writer.close();
inputFile.delete();
boolean successful = tempFile.renameTo(inputFile);
System.out.println(successful);
} catch (IOException ex) {
ex.printStackTrace();
}
}