public class Util extends Object
| Constructor and Description |
|---|
Util()
Creates a new instance of Util
|
| Modifier and Type | Method and Description |
|---|---|
static File |
copyToTempFile(File inputFile,
String prefix,
String suffix,
boolean retainFile)
Copy an existing file into a temporary file.
|
static String |
getMainClassNameForAppClient(ModuleDescriptor moduleDescr)
Returns the main class name for the app client represented by the module descriptor.
|
static String |
loadResource(Class contextClass,
String resourcePath)
Retrieves a resource as a String.
|
static URL |
locateClass(Class target)
Finds the jar file or directory that contains the current class and returns its URI.
|
static String |
replaceTokens(String s,
Properties values)
Searches for placeholders of the form ${token-name} in the input String, retrieves
the property with name token-name from the Properties object, and (if
found) replaces the token in the input string with the property value.
|
static String |
URLtoCodeBase(URL classPathElement)
Returns a codeBase expression, usable in a policy file, for the specified
URL.
|
static File |
writeTextToTempFile(String content,
String prefix,
String suffix)
Writes the provided text to a temporary file marked for deletion on exit.
|
static File |
writeTextToTempFile(String content,
String prefix,
String suffix,
boolean retainFile)
Writes the provided text to a temporary file marked for deletion on exit.
|
public static String replaceTokens(String s, Properties values)
s - String possibly containing tokensvalues - Properties object containing name/value pairs for substitutionpublic static String getMainClassNameForAppClient(ModuleDescriptor moduleDescr) throws IOException, FileNotFoundException, SAXParseException
moduleDescr - the module descriptor for the app client of interestIOExceptionFileNotFoundExceptionSAXParseExceptionpublic static File writeTextToTempFile(String content, String prefix, String suffix, boolean retainFile) throws IOException, FileNotFoundException
content - the content to be writtenprefix - prefix for the temp file, conforming to the File.createTempFile requirementssuffix - suffix for the temp fileretainFile - whether to keep the fileIOException - for any errors writing the temporary fileFileNotFoundException - if the temp file cannot be opened for any reasonpublic static File writeTextToTempFile(String content, String prefix, String suffix) throws IOException, FileNotFoundException
the - content to be writtenprefix - for the temp file, conforming to the File.createTempFile requirementssuffix - for the temp fileIOException - for any errors writing the temporary fileFileNotFoundException - if the temp file cannot be opened for any reasonpublic static URL locateClass(Class target)
the - class, the containing jar file or directory of which is of interestpublic static String loadResource(Class contextClass, String resourcePath) throws IOException
This method does not save the template in a cache. Use the instance method getTemplate for that purpose.
a - class, the class loader of which should be used for searching for the templatethe - path of the resource to load, relative to the contextClassIOException - if the resource is not found or in case of error while loading itpublic static File copyToTempFile(File inputFile, String prefix, String suffix, boolean retainFile) throws IOException, FileNotFoundException
existing - fileIOExceptionFileNotFoundExceptionpublic static String URLtoCodeBase(URL classPathElement) throws FileNotFoundException, URISyntaxException
classPathElement - the URL to be convertedFileNotFoundExceptionURISyntaxExceptionCopyright © 2017. All rights reserved.