Class FileUtils

java.lang.Object
org.codehaus.gmavenplus.util.FileUtils

public class FileUtils extends Object
A collection of file utility methods taken from Guava so we don't have to depend on Guava.
Since:
1.2
Author:
Keegan Witt
  • Method Details

    • getFileExtension

      public static String getFileExtension(File file)
      Returns the file extension without the '.' for the given filename, or the empty string if the file has no extension.
      Parameters:
      file - the file to get the extension from
      Returns:
      the file extension
    • getFileExtension

      public static String getFileExtension(String file)
      Returns the file extension without the '.' for the given filename, or the empty string if the file has no extension.
      Parameters:
      file - the file to get the extension from
      Returns:
      the file extension
    • getNameWithoutExtension

      public static String getNameWithoutExtension(File file)
      Returns the filename without the extension or '.'.
      Parameters:
      file - the file remove the extension from
      Returns:
      the file name without its path or extension
    • getNameWithoutExtension

      public static String getNameWithoutExtension(String file)
      Returns the filename without the extension or '.'.
      Parameters:
      file - the file remove the extension from
      Returns:
      the file name without its path or extension
    • closeQuietly

      public static void closeQuietly(InputStream inputStream)
      Closes the InputStream if it is not null, swallowing any exceptions.
      Parameters:
      inputStream - the InputStream to close
    • closeQuietly

      public static void closeQuietly(OutputStream outputStream)
      Closes the OutputStream if it is not null, swallowing any exceptions.
      Parameters:
      outputStream - the OutputStream to close
    • closeQuietly

      public static void closeQuietly(Reader reader)
      Closes the Reader if it is not null, swallowing any exceptions.
      Parameters:
      reader - the Reader to close
    • closeQuietly

      public static void closeQuietly(Writer writer)
      Closes the Writer if it is not null, swallowing any exceptions.
      Parameters:
      writer - the Writer to close