diff --git a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java index bf3291e03ec6f..384ca07aa6c1a 100644 --- a/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java +++ b/src/main/java/org/elasticsearch/common/io/FileSystemUtils.java @@ -80,11 +80,7 @@ public static int maxOpenFiles(File testDir) { } catch (IOException ioe) { int i = 0; for (RandomAccessFile raf : files) { - try { - raf.close(); - } catch (IOException e) { - // ignore - } + IOUtils.closeWhileHandlingException(raf); new File(testDir, "tmp" + i++).delete(); } if (dirCreated) { @@ -229,33 +225,6 @@ public static void syncFile(File fileToSync, boolean isDir) throws IOException { throw exc; } - public static void copyFile(File sourceFile, File destinationFile) throws IOException { - FileInputStream sourceIs = null; - FileChannel source = null; - FileOutputStream destinationOs = null; - FileChannel destination = null; - try { - sourceIs = new FileInputStream(sourceFile); - source = sourceIs.getChannel(); - destinationOs = new FileOutputStream(destinationFile); - destination = destinationOs.getChannel(); - destination.transferFrom(source, 0, source.size()); - } finally { - if (source != null) { - source.close(); - } - if (sourceIs != null) { - sourceIs.close(); - } - if (destination != null) { - destination.close(); - } - if (destinationOs != null) { - destinationOs.close(); - } - } - } - /** * Check that a directory exists, is a directory and is readable * by the current user