From f33cf35627a4fb3f14c866d560f175f606cfcedc Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 19 Feb 2014 18:57:58 +0000 Subject: [PATCH] * HACK to keep things working on Java 6 --- source/net/sourceforge/tuned/FileUtilities.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/net/sourceforge/tuned/FileUtilities.java b/source/net/sourceforge/tuned/FileUtilities.java index 6bae382a..fecf2661 100644 --- a/source/net/sourceforge/tuned/FileUtilities.java +++ b/source/net/sourceforge/tuned/FileUtilities.java @@ -14,7 +14,6 @@ import java.io.StringWriter; import java.nio.ByteBuffer; import java.nio.channels.FileChannel; import java.nio.charset.Charset; -import java.nio.file.AtomicMoveNotSupportedException; import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Collection; @@ -56,8 +55,13 @@ public final class FileUtilities { // * On Windows ATOMIC_MOVE allows us to rename files even if only lower/upper-case changes (without ATOMIC_MOVE the operation would be ignored) try { java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); - } catch (AtomicMoveNotSupportedException e) { - java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); + } catch (Exception e) { + // HACK to keep things working on Java 6 + if (e.getClass().getName().contains("AtomicMoveNotSupported")) { + java.nio.file.Files.move(source.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING); + } else { + throw e; + } } } catch (LinkageError e) { org.apache.commons.io.FileUtils.moveFile(source, destination); // use "copy and delete" as fallback if standard rename fails