java - tempfile gives wrong absolutepath after renameto -


i'm changing contents of file, therefore read file line line, replace want , write line line tempfiles. when whole file processed, delete original file, , rename tempfile original filename. this

file orginialfile = new file("c:\\java\\workspace\\original.xml"); file tempfile = file.createtempfile("tempfile", ".tmp", new file(c:\\java\\workspace\\")); while ((str_string = reader.readline()) != null) { //read lines , replace , write lines } orginialfile .delete();      tempfile.renameto(new file("c:\\java\\workspace\\original.xml")); 

after done, request absolutepath (tempfile.getabsolutepath();) of temp file. gives me c:\java\workspace\tempfile3729727953777802965.tmp (the number changes every run of program) in stead of c:\java\workspace\original.xml

how come?

i debugged , before moment request absolutepath, checked in c:\java\workspace (windows explorer) , there no tempfile. original file.

so process runs correctly, wanted know why not showing renamed absolutepath. (i use logging)

thx

in documentation of java.io.file, before interoperability java.nio.file package:

instances of file class immutable; is, once created, abstract pathname represented file object never change.

so won't show renamed absolutepath.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -