Class StreamUtil


  • public final class StreamUtil
    extends Object
    Utility methods for opening InputStreams.
    • Method Detail

      • graphConfig

        public static InputStream graphConfig​(Class clazz)
        Open the graph config file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the graph config file
        Returns:
        an InputStream representing the graph config file
      • view

        public static InputStream view​(Class clazz)
        Open the view file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the view file
        Returns:
        an InputStream representing the view file
      • schemas

        public static InputStream[] schemas​(Class clazz)
        Open the schema files located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the schema files
        Returns:
        an array of InputStreams representing the schema files
      • schema

        public static InputStream schema​(Class clazz)
        Open the schema file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the schema file
        Returns:
        an InputStream representing the schema file
      • elementsSchema

        public static InputStream elementsSchema​(Class clazz)
        Open the elements schema file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the elements schema file
        Returns:
        an InputStream representing the elements schema file
      • typesSchema

        public static InputStream typesSchema​(Class clazz)
        Open the types schema file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the types schema file
        Returns:
        an InputStream representing the types schema file
      • storeProps

        public static InputStream storeProps​(Class clazz)
        Open the store properties file located at the same location as the provided class.
        Parameters:
        clazz - the class determining the location of the store properties file
        Returns:
        an InputStream representing the store properties file
      • openStreams

        public static InputStream[] openStreams​(Class clazz,
                                                String folderPath)
        Open all of the files found in the specified subdirectory of the provided class.
        Parameters:
        clazz - the class location
        folderPath - the subdirectory in the class location
        Returns:
        an array of InputStreams representing the files found
      • openStreams

        public static InputStream[] openStreams​(URI... uris)
                                         throws IOException
        Create an array of InputStreams from the provided list of URIs.
        Parameters:
        uris - the URIs to open as input streams
        Returns:
        an array of input streams
        Throws:
        IOException - if there was an error opening the streams
      • openStream

        public static InputStream openStream​(URI uri)
                                      throws IOException
        Create an InputStreams from the provided URI.
        Parameters:
        uri - the URI to open as an input stream
        Returns:
        an input streams
        Throws:
        IOException - if there was an error opening the stream
      • closeStreams

        public static int closeStreams​(InputStream... inputStreams)
        Safely close the supplied list of InputStreams.
        Parameters:
        inputStreams - the input streams to close
        Returns:
        an integer indicating the number of streams which were successfully closed.
      • openStream

        public static InputStream openStream​(Class clazz,
                                             String path)
                                      throws IllegalArgumentException
        Open the file found at the the specified path under the location of the given class.
        Parameters:
        clazz - the class location
        path - the path in the class location
        Returns:
        an input stream representating the requested file
        Throws:
        IllegalArgumentException - if there was an error opening the stream
      • formatPathForOpenStream

        public static String formatPathForOpenStream​(String path)
        Format a path to ensure that it begins with a '/' character.
        Parameters:
        path - the path to format
        Returns:
        a correctly formatted path string