public class ResourceUtilities
extends java.lang.Object
Constructor and Description |
---|
ResourceUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
copyResourceToFile(java.lang.String resource,
java.io.RandomAccessFile randomAccessFile)
Copies the resource with the given name to a file on the file system..
|
static java.lang.String |
copyResourceToTempFile(java.lang.String resource,
java.nio.file.Path destinationOrNull,
java.lang.String prefix,
java.lang.String postfix,
boolean cleanUpOldResources)
Copies the resource with the given name to a temporary file.
|
static java.lang.String |
copyResourceToTempFile(java.lang.String resource,
java.lang.String prefix,
java.lang.String postfix)
Copies the resource with the given name to a temporary file.
|
static boolean |
tryCopyResourceToFile(java.lang.String resource,
java.nio.file.Path filename,
java.io.RandomAccessFile randomAccessFile,
boolean verbose,
java.lang.String logPrefixOrNull)
Tries to copy the resource with the given name to a file on the file system.
|
static java.lang.String |
tryCopyResourceToTempFile(java.lang.String resource,
java.lang.String prefix,
java.lang.String postfix)
Tries to copy the resource with the given name to a temporary file.
|
static java.lang.String |
tryCopyResourceToTempFile(java.lang.String resource,
java.lang.String prefix,
java.lang.String postfix,
boolean cleanUpOldResources)
Tries to copy the resource with the given name to a temporary file.
|
static java.lang.String |
tryCopyResourceToTempFile(java.lang.String resource,
java.lang.String prefix,
java.lang.String postfix,
boolean cleanUpOldResources,
boolean verbose,
java.lang.String logPrefixOrNull)
Tries to copy the resource with the given name to a temporary file.
|
public static java.lang.String tryCopyResourceToTempFile(java.lang.String resource, java.lang.String prefix, java.lang.String postfix)
resource
- The name of the resource to copy.prefix
- The prefix to use for the temporary name.postfix
- The postfix to use for the temporary name.null
, if the resource could not be copied.public static java.lang.String tryCopyResourceToTempFile(java.lang.String resource, java.lang.String prefix, java.lang.String postfix, boolean cleanUpOldResources)
resource
- The name of the resource to copy.prefix
- The prefix to use for the temporary name.postfix
- The postfix to use for the temporary name.cleanUpOldResources
- If true
, remove old leftover temporary files for this prefix and postfix.null
, if the resource could not be copied.public static java.lang.String tryCopyResourceToTempFile(java.lang.String resource, java.lang.String prefix, java.lang.String postfix, boolean cleanUpOldResources, boolean verbose, java.lang.String logPrefixOrNull)
resource
- The name of the resource to copy.prefix
- The prefix to use for the temporary name.postfix
- The postfix to use for the temporary name.cleanUpOldResources
- If true
, remove old leftover temporary files for this prefix and postfix.verbose
- If true
, print error to stderr
if copying fails.logPrefixOrNull
- If verbose == true
, a prefix for logging failure conditions.null
, if the resource could not be copied.public static java.lang.String copyResourceToTempFile(java.lang.String resource, java.lang.String prefix, java.lang.String postfix) throws IOExceptionUnchecked
resource
- The name of the resource to copy.prefix
- The prefix to use for the temporary name.postfix
- The postfix to use for the temporary name.java.lang.IllegalArgumentException
- If the resource cannot be found in the class path.IOExceptionUnchecked
- If an IOException
occurs.public static java.lang.String copyResourceToTempFile(java.lang.String resource, java.nio.file.Path destinationOrNull, java.lang.String prefix, java.lang.String postfix, boolean cleanUpOldResources) throws IOExceptionUnchecked
resource
- The name of the resource to copy.prefix
- The prefix to use for the temporary name.postfix
- The postfix to use for the temporary name.cleanUpOldResources
- If true
, remove old leftover temporary files for this prefix and postfix.java.lang.IllegalArgumentException
- If the resource cannot be found in the class path.IOExceptionUnchecked
- If an IOException
occurs.public static boolean tryCopyResourceToFile(java.lang.String resource, java.nio.file.Path filename, java.io.RandomAccessFile randomAccessFile, boolean verbose, java.lang.String logPrefixOrNull) throws IOExceptionUnchecked
This method catches all exceptions and returns a status flag.
resource
- The name of the resource to copy.filename
- The name of the file to copy the resource content to.randomAccessFile
- The destination file to copy the resource content to.verbose
- If true
, print error information to stderr
if the copying fails.logPrefixOrNull
- If verbose == true
, a prefix for logging failure conditions.true
if the copying was successfull and false
otherwise.IOExceptionUnchecked
public static void copyResourceToFile(java.lang.String resource, java.io.RandomAccessFile randomAccessFile) throws IOExceptionUnchecked
resource
- The name of the resource to copy.randomAccessFile
- The destination file to copy the resource content to.java.lang.IllegalArgumentException
- If the resource cannot be found in the class path.IOExceptionUnchecked
- If an IOException
occurs.