File Move throws IOException due to different mount volume in Linux
Hi my java program has to move the files to a folder which is in different mounted folder. I want to treat it as a normal folder path and move the file using
boolean success = file.renameTo(new File(dir, file.getName()));
it gives the status as false always and file not moved.
When I try with the filechannel.transferF开发者_如何学Crom(fcSource, 0, fcSource.size());
it is throwing IO Exception.
SEVERE 20110720 15.41.29 AccessLogProcessor:moveToArchive-File
[/opt/apache2/logs/access_log.20110620.0015.tmp] move to
[/opt/ahache2/logs/old] not success.. Try Special move with filechannel
SEVERE 20110720 15.41.29 AccessLogProcessor:moveToArchive-SpecialFileMove for file
[/opt/apache2/logs/access_log.20110620.0015.tmp] failure
ERROR:java.io.IOException: **No such file or directory
The destination folder in linux looks like normal and my id has no permission issue. The folder /opt/ahache2/logs/old
is a mounted one.
About the 'renameTo'
returning false, and according to the API:
Whether or not this method can move a file from one filesystem to another is platform-dependent. The return value should always be checked to make sure that the rename operation was successful.
So maybe you cannot use 'renameTo'
to do what you want to do.
精彩评论