diff --git a/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java b/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java index f42a89c1fa..5445f006f1 100644 --- a/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java @@ -27,7 +27,9 @@ import org.springframework.lang.Nullable; * @author Rob Harrop * @author Juergen Hoeller * @since 2.5.3 + * @deprecated as of Spring Framework 5.0, in favor of native NIO API usage */ +@Deprecated public abstract class FileSystemUtils { /** @@ -60,7 +62,8 @@ public abstract class FileSystemUtils { * @throws IOException in the case of I/O errors */ public static void copyRecursively(@Nullable File src, File dest) throws IOException { - Assert.isTrue(src != null && (src.isDirectory() || src.isFile()), "Source File must denote a directory or file"); + Assert.isTrue(src != null && (src.isDirectory() || src.isFile()), + "Source File must denote a directory or file"); Assert.notNull(dest, "Destination File must not be null"); doCopyRecursively(src, dest); } @@ -88,9 +91,7 @@ public abstract class FileSystemUtils { dest.createNewFile(); } catch (IOException ex) { - IOException ioex = new IOException("Failed to create file: " + dest); - ioex.initCause(ex); - throw ioex; + throw new IOException("Failed to create file: " + dest, ex); } FileCopyUtils.copy(src, dest); } diff --git a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java index e9819aa170..dd56271ac3 100644 --- a/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/util/FileSystemUtilsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import static org.junit.Assert.*; /** * @author Rob Harrop */ +@Deprecated public class FileSystemUtilsTests { @Test