• Post Reply Bookmark Topic Watch Topic
  • New Topic

File.renameTo() feature

 
George Brown
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone offer an explanation why the following code works under various unix machines, but does not work under Windows (tested on NT and 98)? It's foxing me...
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The last time I searched, this was reported numerous times as a bug to Sun. As of jdk 1.2.2_02, they had yet to correct the problem. I don't know nor have I tryed to determine if the problem still exists with the release of 1.2.2_06 or 1.3. If you have a real need, you'll need to institue your own renameTo() method. In it you will need to open the file you want to rename, read it in and then open a new file with the new name and wite the info out and finally delete the original file (not very pretty).
Hope this helps
 
George Brown
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've discovered something about it that's slightly more specific: I was doing all my testing on NT from the C:\TEMP directory, which happens to be the default place that the 'createTempFile()' method creates its files.
Running the noddy from there always returns 'false' for the rename, but I've just discovered that if I change my current working directory to any other directory and execute it there, it returns 'true'... my guess is that it is possibly something to do with the pathname mixing '.' up with the absolute pathname?
I'm using 1.2.2-W on NT (that must be the 'whatever' release)
 
Carl Trusiak
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm using 1.2.2-W on NT (that must be the 'whatever' release)

LOL,
The problem I was seeing was when I renamed several files in a row, only one of them would actually get renamed even though the method returned true for each. The bug database had it listed as 'inconsistant results' so, I'd be careful trying to use this method.


[This message has been edited by Carl Trusiak (edited November 01, 2000).]
 
Patrick Weiss
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George !
Such a long time since you dealed with this bug, isn't it ?
But, please, have you found a solution for that ?
Originally posted by George Brown:
[B]Can anyone offer an explanation why the following code works under various unix machines, but does not work under Windows (tested on NT and 98)? It's foxing me...
[/B]


------------------
ptckweiss
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!