Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes File Moving on Mounted Devices (NFS/ Samba) Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "File Moving on Mounted Devices (NFS/ Samba)" Watch "File Moving on Mounted Devices (NFS/ Samba)" New topic
Author

File Moving on Mounted Devices (NFS/ Samba)

Z Zia
Greenhorn

Joined: Oct 03, 2004
Posts: 24
Hello,

An Interesting Observation: We can move files from Java using renameTo() function, one of my solution is distributed in 3 tiers. First 2 on linux (NFS mapping) and 3 tier is on windows (Samba mapping). When I try to move files from one linux system folder to other (NFS) or linux system to windows system folder(samba), it doesn't returns any errors but files are not transmitted.

Any clues?

Regards,
Zeeshan
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

If you move a file on a single device, only an entry in a filetable needs to be changed, for example from /mnt/hdf4/foo/bar.txt to /mnt/hdf4/bar/bar/bar/bar.txt. The file itself isn't read or written. It's just renamed.

If you try to write it to a different device, it needs to be read and written, and can't just be renamed.


http://home.arcor.de/hirnstrom/bewerbung
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

renameTo() fails by returning "false"; it will generally fail when, as Stefan says, you try to rename something onto another device. You must always check the return value of "renameTo()" and fall back to bytewise-copying on failure.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: File Moving on Mounted Devices (NFS/ Samba)
 
Similar Threads
Creating file on a server through a jsp which is running on another server
NFS and Samba Mountings
Need help to Copy a File from Unix to Windows
Access Linux NFS from windows?
Folder sharing in Unix