Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHARED-893] deprecate more file methods we don't need in Java 7+ #36

Merged
merged 3 commits into from
May 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions src/main/java/org/apache/maven/shared/utils/io/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,9 @@ public static void fileWriteArray( @Nonnull File file, @Nullable String encoding
* Deletes a file.
*
* @param fileName the path of the file to delete
* @deprecated use {@code Files.delete(Paths.get(fileName))}
*/
@Deprecated
public static void fileDelete( @Nonnull String fileName )
{
File file = new File( fileName );
Expand All @@ -481,11 +483,11 @@ public static void fileDelete( @Nonnull String fileName )
/**
* Given a directory and an array of extensions return an array of compliant files.
* <p/>
* The given extensions should be like "java" and not like ".java"
* The given extensions should be like "java" and not like ".java".
*
* @param directory the path of the directory
* @param extensions an array of expected extensions
* @return tn array of files for the wanted extensions
* @return an array of files for the wanted extensions
*/
public static String[] getFilesFromExtension( @Nonnull String directory, @Nonnull String... extensions )
{
Expand Down Expand Up @@ -573,10 +575,10 @@ private static boolean isValidFile( @Nonnull String file, @Nonnull String... ext
}

/**
* Simple way to make a directory
* Simple way to make a directory.
*
* @param dir the directory to create
* @throws IllegalArgumentException if the dir contains illegal Windows characters under Windows OS.
* @throws IllegalArgumentException if the dir contains illegal Windows characters under Windows OS
* @see #INVALID_CHARACTERS_FOR_WINDOWS_FILE_NAME
*/
public static void mkdir( @Nonnull String dir )
michael-o marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -682,7 +684,7 @@ public static boolean contentEquals( @Nonnull final File file1, @Nonnull final F
}

/**
* Remove extension from filename. E.g.
* Remove extension from a path. E.g.
* <pre>
* foo.txt --> foo
* a\b\c.jpg --> a\b\c
Expand All @@ -691,7 +693,9 @@ public static boolean contentEquals( @Nonnull final File file1, @Nonnull final F
*
* @param filename the path of the file
* @return the filename minus extension
* @deprecated use {@code org.apache.commons.io.FilenameUtils.removeExtension()}
*/
@Deprecated
@Nonnull public static String removeExtension( @Nonnull final String filename )
{
String ext = extension( filename );
Expand All @@ -706,7 +710,7 @@ public static boolean contentEquals( @Nonnull final File file1, @Nonnull final F
}

/**
* Get extension from filename. E.g.
* Get extension from a path. E.g.
*
* <pre>
* foo.txt --> "txt"
Expand All @@ -716,7 +720,9 @@ public static boolean contentEquals( @Nonnull final File file1, @Nonnull final F
*
* @param filename the path of the file
* @return the extension of filename or "" if none
* @deprecated use {@code org.apache.commons.io.FilenameUtils.getExtension()}
*/
@Deprecated
@Nonnull public static String getExtension( @Nonnull final String filename )
{
return extension( filename );
Expand All @@ -734,7 +740,9 @@ public static boolean contentEquals( @Nonnull final File file1, @Nonnull final F
* @throws IOException if <code>source</code> does not exist, the file in
* <code>destinationDirectory</code> cannot be written to, or an IO error
* occurs during copying.
* @deprecated use {@code org.apache.commons.io.FileUtils.copyFileToDirectory()}
*/
@Deprecated
public static void copyFileToDirectory( @Nonnull final File source, @Nonnull final File destinationDirectory )
throws IOException
{
Expand Down Expand Up @@ -784,7 +792,9 @@ private static void copyFileToDirectoryIfModified( @Nonnull final File source,
* @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be
* written to, or an IO error occurs during copying
* @throws java.io.FileNotFoundException if <code>destination</code> is a directory
* @deprecated use {@code org.apache.commons.io.FileUtils.copyFile()}
michael-o marked this conversation as resolved.
Show resolved Hide resolved
*/
@Deprecated
public static void copyFile( @Nonnull final File source, @Nonnull final File destination )
throws IOException
{
Expand Down Expand Up @@ -913,7 +923,9 @@ public static void copyURLToFile( @Nonnull final URL source, @Nonnull final File
* <li><code>destination</code> cannot be written to</li>
* <li>an IO error occurs during copying</li>
* </ul>
* @deprecated use {@code org.apache.commons.io.FileUtils.copyInputStreamToFile()}
michael-o marked this conversation as resolved.
Show resolved Hide resolved
*/
@Deprecated
private static void copyStreamToFile( @Nonnull @WillClose final InputStream source,
@Nonnull final File destination )
throws IOException
Expand Down Expand Up @@ -955,7 +967,9 @@ private static void copyStreamToFile( @Nonnull @WillClose final InputStream sour
*
* @param path the path to normalize
* @return the normalized String, or <code>null</code> if too many ..'s.
* @deprecated use {@code org.apache.commons.io.FileNameUtils.normalize()}
*/
@Deprecated
@Nonnull public static String normalize( @Nonnull final String path )
{
String normalized = path;
Expand Down Expand Up @@ -1125,21 +1139,23 @@ public static void forceDelete( @Nonnull final File file )
/**
* deletes a file.
*
* @param file The file to delete
* @param file the file to delete
* @throws IOException if the file cannot be deleted
* @deprecated use {@code java.nio.files.Files.delete(file.toPath())}
*/


@Deprecated
public static void delete( @Nonnull File file )
throws IOException
{
Files.delete( file.toPath() );
}

/**
* @param file The file.
* @param file the file
* @return true / false
* @deprecated use {@code java.nio.files.Files.delete(file.toPath())}
*/
@Deprecated
public static boolean deleteLegacyStyle( @Nonnull File file )
{
try
Expand Down