public class FileUtils extends Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static File |
createUniqueFile(File directory,
String filename)
Creates a File that is unique in the specified directory.
|
static String |
getFileContentAsString(File file,
Constants.Encoding encoding)
Reads the content of a File instance and returns it as a String of either text or base64 encoded text.
|
static String |
getFilenameFromContentDisposition(javax.ws.rs.core.Response response)
Get the filename from the "Content-Disposition" header of a JAX-RS response.
|
static String |
getReaderContentAsString(Reader reader)
Reads the content of a Reader instance and returns it as a String.
|
static String |
readFileContents(File file)
Reads the contents of a File to a String.
|
public static File createUniqueFile(File directory, String filename) throws IOException
directory
- the directory to create the file infilename
- the base filename with extensionIOException
- if any error occurs during file creationpublic static String getFilenameFromContentDisposition(javax.ws.rs.core.Response response)
response
- the JAX-RS Response instance to get the "Content-Disposition" header filename frompublic static String readFileContents(File file) throws IOException
file
- the File instance to read the contents fromIOException
- if any errors occur while opening or reading the filepublic static String getReaderContentAsString(Reader reader) throws IOException
reader
- the Reader instance to read the content fromIOException
- if any error occurspublic static String getFileContentAsString(File file, Constants.Encoding encoding) throws IOException
file
- the File instance to read fromencoding
- whether to encode as Base64 or as Text, defaults to Text if nullIOException
- if any error occursCopyright © 2019. All rights reserved.