aspose file tools*
The moose likes Beginning Java and the fly likes File.renameTo does not work on Ubantu Linux 9.X version Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "File.renameTo does not work on Ubantu Linux 9.X version" Watch "File.renameTo does not work on Ubantu Linux 9.X version" New topic
Author

File.renameTo does not work on Ubantu Linux 9.X version

Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374


Has anybody tried this command method on Linux plateform? The same code works on Windows.

Work around could be copy the file to archive folder and then remove from source folder.
Geoff Jefferson
Ranch Hand

Joined: Apr 09, 2009
Posts: 102
That's weird. In my programs I've always entered the path with the backslash.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Geoff Jefferson wrote:In my programs I've always entered the path with the backslash.


This is LINUUUUUUUUUUUUUUUX!!!
sorry, couldn't help it
But seriously, Linux uses / instead of \ so that's definitely not the problem.

Vikas, do you have enough rights on both the source folder (/home/CSVFileParsing/Source), destination folder (/home/CSVFileParsing/Archive/) and their shared parents (/home/CSVFileParsing/ and /home/). In other words, can you move the file from the command line:
If not then you can try in Java all you want, but the file system is holding you back.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Another possibility: Is one of those directories on a separate filesystem? renameTo() won't work in that case, you'll have to move (i.e., copy/delete) the file.


[Jess in Action][AskingGoodQuestions]
Vikas Kapoor
Ranch Hand

Joined: Aug 16, 2007
Posts: 1374
Spot on Rob. It's indeed permission issue.

Thank you Guys.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Ernest Friedman-Hill wrote:Another possibility: Is one of those directories on a separate filesystem? renameTo() won't work in that case, you'll have to move (i.e., copy/delete) the file.

Not quite. I have successfully used renameTo on Windows between different partitions, and even with network shares.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40041
    
  28
But if it's on a Linux partition which the user doesn't have "write" permission on . . .
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19783
    
  20

Then it's a rights issue, as I first suspected and is confirmed by Vikas. It has nothing to do with the remote-ness of the file system.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File.renameTo does not work on Ubantu Linux 9.X version