public class FileUtils
extends java.lang.Object
Constructor and Description |
---|
FileUtils() |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
createUniqueFile(java.io.File directory,
java.lang.String filename)
Creates a File that is unique in the specified directory.
|
static java.lang.String |
getFileContentAsString(java.io.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 java.lang.String |
getFilenameFromContentDisposition(javax.ws.rs.core.Response response)
Get the filename from the "Content-Disposition" header of a JAX-RS response.
|
static java.lang.String |
getReaderContentAsString(java.io.Reader reader)
Reads the content of a Reader instance and returns it as a String.
|
static java.lang.String |
readFileContents(java.io.File file)
Reads the contents of a File to a String.
|
public static java.io.File createUniqueFile(java.io.File directory, java.lang.String filename) throws java.io.IOException
directory
- the directory to create the file infilename
- the base filename with extensionjava.io.IOException
- if any error occurs during file creationpublic static java.lang.String getFilenameFromContentDisposition(javax.ws.rs.core.Response response)
response
- the JAX-RS Response instance to get the "Content-Disposition" header filename frompublic static java.lang.String readFileContents(java.io.File file) throws java.io.IOException
file
- the File instance to read the contents fromjava.io.IOException
- if any errors occur while opening or reading the filepublic static java.lang.String getReaderContentAsString(java.io.Reader reader) throws java.io.IOException
reader
- the Reader instance to read the content fromjava.io.IOException
- if any error occurspublic static java.lang.String getFileContentAsString(java.io.File file, Constants.Encoding encoding) throws java.io.IOException
file
- the File instance to read fromencoding
- whether to encode as Base64 or as Text, defaults to Text if nulljava.io.IOException
- if any error occurs