Class Util


  • public class Util
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Util()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.io.InputStream getResourceOrFile​(java.lang.String name)
      Open a stream from a resource or a file.
      static void getURL​(java.lang.String url, java.lang.String file)
      Copy a URL to a local file
      static java.lang.String replace​(java.lang.String original, java.lang.String match, java.lang.String replace, boolean all)  
      static java.lang.String replacePrefix​(java.lang.String value, java.lang.String[] prefixes)
      Replace one prefix string with another.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Util

        public Util()
    • Method Detail

      • replace

        public static java.lang.String replace​(java.lang.String original,
                                               java.lang.String match,
                                               java.lang.String replace,
                                               boolean all)
      • getURL

        public static void getURL​(java.lang.String url,
                                  java.lang.String file)
                           throws java.lang.Exception
        Copy a URL to a local file
        Throws:
        java.lang.Exception
      • getResourceOrFile

        public static java.io.InputStream getResourceOrFile​(java.lang.String name)
                                                     throws java.io.IOException
        Open a stream from a resource or a file. If a file with the given name exists then return a stream from that file, otherwise try to open it as a system resource.
        Parameters:
        name - The name of the resource or file.
        Throws:
        java.io.IOException
      • replacePrefix

        public static java.lang.String replacePrefix​(java.lang.String value,
                                                     java.lang.String[] prefixes)
        Replace one prefix string with another. This is used, e.g., to replace URLs with local file access.
        Parameters:
        value - The string to be modifed.
        prefixes - A 2 element array where we will look for the first prefix at the beginning of value and if found replace it with the second prefix.
        Returns:
        The string with the prefix replaced if found.