• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

File.renameTo() feature

 
Ranch Hand
Posts: 919
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic