Home arrow static arrow Java Programming [Archive] - File.renamTo() on NFS mounted files
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - File.renamTo() on NFS mounted files
This topic has 1 reply on 1 page.

Posts:2
Registered: 1/7/04
File.renamTo() on NFS mounted files  
Jul 22, 2004 6:37 AM



 
Hello everyone!

This is really a tricky thing, so I would wonder, if someone could give me a hint, but I believe in the Java spirit :-)

I coded a little file demon on our Solaris environment, that infinitely queries a directory for new files and moves them to a final destination. The source diretory is an NFS mounted one, the target is local. The application is invoked by a user with the same user id, the file was generated with on the other machine. On command line, I've no problem to move the file with the move command (file rights for the user are +rw, no forcing needed).
When I try to do the same with the application, the File.renameTo() function always returns false without raising an exception.

In fact, we're also running an instance from the same application, which uses a local source directory and has no problems moving the file.

We already tried to use truss to get some debugging information, why the file could not be moved. The result was an error 18 EXDEV , google meant to identify that as ""Cross-device link " error.

Any suggestions? Is the Java method not capable of moving NFS mounted files to local directories?

PS: I don't want to use a workaorund by invoking the "mv" command instead of the oop way using the File object.
 

Posts:11,200
Registered: 7/22/99
Re: File.renamTo() on NFS mounted files  
Jul 22, 2004 11:18 AM (reply 1 of 1)



 
Like the API documentation of the renameTo method says, whether or not it can rename a file from one file system to another is platform-dependent. On your system it appears to be that it can't.

If you don't want to use the mv command, you have to first copy the file to its new location (common read and write I/O) and then delete the old file. This is what the mv command does, too.
 
This topic has 1 reply on 1 page.