* support Java IO copy-move

This commit is contained in:
Reinhard Pointner 2011-12-27 02:26:40 +00:00
parent b82943439c
commit 827185d1f4
1 changed files with 3 additions and 3 deletions

View File

@ -15,7 +15,6 @@ import java.io.StringWriter;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -69,13 +68,14 @@ public final class FileUtilities {
private static void renameFileNIO2(File source, File destination) throws IOException { private static void renameFileNIO2(File source, File destination) throws IOException {
Files.move(source.toPath(), destination.toPath()); java.nio.file.Files.move(source.toPath(), destination.toPath());
} }
private static void renameFileIO(File source, File destination) throws IOException { private static void renameFileIO(File source, File destination) throws IOException {
if (!source.renameTo(destination)) { if (!source.renameTo(destination)) {
throw new IOException("Failed to rename file: " + source.getName()); // try using Guava IO utilities, that'll just copy files if renameTo() fails
com.google.common.io.Files.move(source, destination);
} }
} }