Class IOUtil


  • public class IOUtil
    extends java.lang.Object
    Collection of IO related utilities
    • Constructor Summary

      Constructors 
      Constructor Description
      IOUtil()  
      IOUtil​(long cPtr, boolean cMemoryOwn)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void delete()  
      static java.lang.String getAbsoluteFileName​(java.lang.String file)
      returns the absolute filename of file.
      static long getCPtr​(IOUtil obj)  
      static vector_s getFilesInFolder​(java.lang.String path, boolean recursive)
      Returns files in the folder specified by path

      Throws rw::core::Exception if unable to obtain file names.

      static vector_s getFilesInFolder​(java.lang.String path, boolean recursive, boolean addPath)
      Returns files in the folder specified by path

      Throws rw::core::Exception if unable to obtain file names.

      static vector_s getFilesInFolder​(java.lang.String path, boolean recursive, boolean addPath, java.lang.String mask)
      Returns files in the folder specified by path

      Throws rw::core::Exception if unable to obtain file names.

      static void getFilesInFolder​(java.lang.String path, java.lang.String fileMask, boolean recursive, boolean addPath, vector_s result)
      get all files in a folder
      static long getFileSize​(java.lang.String filename)
      get size of file
      static java.lang.String getFirstXMLElement​(java.lang.String filename)
      extracts the first element tag in any xml document.

      throws if not xml document or file cannot be openned
      static java.lang.String getFirstXMLElement​(SWIGTYPE_p_std__istream inputStream)
      extracts the first element tag in any xml document.

      throws if not xml document
      static SWIGTYPE_p_std__time_t getLastFileWrite​(java.lang.String filename)
      get the last date of writing of the file filename
      static boolean isLittleEndian()
      tests if this machine use little or big endian.
      static void readFile​(java.lang.String file_name, vector_c result)
      Read the contents of a file.

      The contents of the file file_name are read into the buffer result.
      static java.lang.String resolveFileName​(java.lang.String filename, vector_s extensions)
      Attach to filename the proper extension.

      Find the the suffix of extensions that when appended to filename
      yields the file name for readable file.

      For suffix of extensions, lower case and upper case versions of this
      suffix are also considered.

      The file name filename as is with nothing prepended at all is
      considered as the first thing.

      If filename can't be resolved to a readable file, an informative error
      message is thrown.

      static void rwAssert​(java.lang.String expression, java.lang.String file, int line)
      Emit an assertion message and kill the program.

      rwAssert() is called by the RW_ASSERT() macro.

      rwAssert() is for internal use only.

      • Methods inherited from class java.lang.Object

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

      • IOUtil

        public IOUtil​(long cPtr,
                      boolean cMemoryOwn)
      • IOUtil

        public IOUtil()
    • Method Detail

      • getCPtr

        public static long getCPtr​(IOUtil obj)
      • delete

        public void delete()
      • readFile

        public static void readFile​(java.lang.String file_name,
                                    vector_c result)
        Read the contents of a file.

        The contents of the file file_name are read into the buffer result. The
        result buffer is resized to match the length of the input.

        Files can be lengthy which is why the result is returned via the result
        parameter (an alternative would be to return a smart pointer to a vector).

        An exception is thrown if the file can't be opened or can't be read.

        Parameters:
        file_name - [in] The name of the file.

        result - [out] Buffer to which the file contents are written.
      • resolveFileName

        public static java.lang.String resolveFileName​(java.lang.String filename,
                                                       vector_s extensions)
        Attach to filename the proper extension.

        Find the the suffix of extensions that when appended to filename
        yields the file name for readable file.

        For suffix of extensions, lower case and upper case versions of this
        suffix are also considered.

        The file name filename as is with nothing prepended at all is
        considered as the first thing.

        If filename can't be resolved to a readable file, an informative error
        message is thrown.

        Parameters:
        filename - [in] The file name to resolve.

        extensions - [in] The sequence of file name suffixes.

        Returns:
        The filename with extension
      • rwAssert

        public static void rwAssert​(java.lang.String expression,
                                    java.lang.String file,
                                    int line)
        Emit an assertion message and kill the program.

        rwAssert() is called by the RW_ASSERT() macro.

        rwAssert() is for internal use only.

        Parameters:
        expression - [in] The thing that wasn't true.

        file - [in] The originating file name.

        line - [in] The originating line number.
      • getAbsoluteFileName

        public static java.lang.String getAbsoluteFileName​(java.lang.String file)
        returns the absolute filename of file. If file is
        absolute filename then file is returned. If not, then
        working directory path is appended to file.
        Parameters:
        file - [in] the relative or absolute filename
      • isLittleEndian

        public static boolean isLittleEndian()
        tests if this machine use little or big endian.
        Returns:
        true if machine
      • getFilesInFolder

        public static vector_s getFilesInFolder​(java.lang.String path,
                                                boolean recursive,
                                                boolean addPath,
                                                java.lang.String mask)
        Returns files in the folder specified by path

        Throws rw::core::Exception if unable to obtain file names.

        Parameters:
        path - [in] Path to search in
        recursive - [in] if true files in subfolders are also added
        addPath - [in] If true both path and filenames are returned. Otherwise only the
        filenames are returned.
        mask - [in] Mask to filter filenames. Example: "*.dll" to return all DLL files.
        Returns:
        Files located at path.
      • getFilesInFolder

        public static vector_s getFilesInFolder​(java.lang.String path,
                                                boolean recursive,
                                                boolean addPath)
        Returns files in the folder specified by path

        Throws rw::core::Exception if unable to obtain file names.

        Parameters:
        path - [in] Path to search in
        recursive - [in] if true files in subfolders are also added
        addPath - [in] If true both path and filenames are returned. Otherwise only the
        filenames are returned.

        Returns:
        Files located at path.
      • getFilesInFolder

        public static vector_s getFilesInFolder​(java.lang.String path,
                                                boolean recursive)
        Returns files in the folder specified by path

        Throws rw::core::Exception if unable to obtain file names.

        Parameters:
        path - [in] Path to search in
        recursive - [in] if true files in subfolders are also added


        Returns:
        Files located at path.
      • getFilesInFolder

        public static void getFilesInFolder​(java.lang.String path,
                                            java.lang.String fileMask,
                                            boolean recursive,
                                            boolean addPath,
                                            vector_s result)
        get all files in a folder
        Parameters:
        path - [in] folder path
        fileMask - [in] file mask. Example: "*.dll" to return all DLL files.
        recursive - [in] if true files in subfolders are also added
        addPath - [in] if true then folder paths are added to solution
        result - [out] all files and if addPath
      • getFileSize

        public static long getFileSize​(java.lang.String filename)
        get size of file
        Parameters:
        filename - [in] name of file
        Returns:
        the size of file in bytes
      • getLastFileWrite

        public static SWIGTYPE_p_std__time_t getLastFileWrite​(java.lang.String filename)
        get the last date of writing of the file filename
        Parameters:
        filename - [in] name of file
        Returns:
        time of modification
      • getFirstXMLElement

        public static java.lang.String getFirstXMLElement​(java.lang.String filename)
        extracts the first element tag in any xml document.

        throws if not xml document or file cannot be openned
        Parameters:
        filename - [in] name of the xml file
        Returns:
        name of first xml element
      • getFirstXMLElement

        public static java.lang.String getFirstXMLElement​(SWIGTYPE_p_std__istream inputStream)
        extracts the first element tag in any xml document.

        throws if not xml document
        Parameters:
        inputStream - [in] ifstream containing the xml document
        Returns:
        name of first xml element