Class Util


  • public class Util
    extends Object
    Utility methods
    Author:
    tjquinn
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • getArchiveFactory

        public static ArchiveFactory getArchiveFactory()
      • writeTextToTempFile

        public static File writeTextToTempFile​(String content,
                                               String prefix,
                                               String suffix,
                                               boolean retainTempFiles)
                                        throws IOException,
                                               FileNotFoundException
        Writes the provided text to a temporary file marked for deletion on exit.
        Parameters:
        content - the content to be written
        prefix - for the temp file, conforming to the File.createTempFile requirements
        suffix - for the temp file
        Returns:
        File object for the newly-created temp file
        Throws:
        IOException - for any errors writing the temporary file
        FileNotFoundException - if the temp file cannot be opened for any reason
      • replaceTokens

        public 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.
        Parameters:
        s - String possibly containing tokens
        values - Properties object containing name/value pairs for substitution
        Returns:
        the original string with tokens substituted using their values from the Properties object
      • toXMLEscaped

        public static String toXMLEscaped​(String content)