Package org.codehaus.gmavenplus.util
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 Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseQuietly(InputStream inputStream)Closes the InputStream if it is not null, swallowing any exceptions.static voidcloseQuietly(OutputStream outputStream)Closes the OutputStream if it is not null, swallowing any exceptions.static voidcloseQuietly(Reader reader)Closes the Reader if it is not null, swallowing any exceptions.static voidcloseQuietly(Writer writer)Closes the Writer if it is not null, swallowing any exceptions.static StringgetFileExtension(String file)Returns the file extension without the '.' for the given filename, or the empty string if the file has no extension.static StringgetNameWithoutExtension(String file)Returns the filename without the extension or '.'.
-
-
-
Method Detail
-
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(String file)
Returns the filename without the extension or '.'.- Parameters:
file- the name of 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
-
-