Class IOUtils


  • public class IOUtils
    extends java.lang.Object
    Utility-class for Gridarta's I/O.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String MAP_ENCODING
      Encoding to use for maps and other data.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull java.io.File findPathFile​(@NotNull java.lang.String name)
      Searches for file on all paths specified by the environment variable "PATH".
      static @NotNull java.io.File getCanonicalFile​(@NotNull java.io.File file)
      Calls File.getCanonicalFile().
      static @NotNull java.lang.String getCanonicalPath​(@NotNull java.io.File file)
      Calls File.getCanonicalPath().
      static @NotNull java.io.File getFile​(@NotNull java.io.File dir, @NotNull java.lang.String fileName)
      Returns a File instance for a resource that is a regular file on the file system.
      static @NotNull java.net.URL getResource​(@NotNull java.io.File dir, @NotNull java.lang.String fileName)
      Get the URL of a resource.
      • Methods inherited from class java.lang.Object

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

      • MAP_ENCODING

        @NotNull
        public static final @NotNull java.lang.String MAP_ENCODING
        Encoding to use for maps and other data. The encoding given here is used for reading and writing maps. You shouldn't change this only because you use an UTF-8 system or so, since the encoding used here MUST be compatible with the server and the client and the maps. The paragraph sign § is the critical character.
        See Also:
        Constant Field Values
        Todo:
        once the mailing list decided on the § character, eventually replace by "us-ascii".
    • Method Detail

      • getResource

        @NotNull
        public static @NotNull java.net.URL getResource​(@NotNull
                                                        @NotNull java.io.File dir,
                                                        @NotNull
                                                        @NotNull java.lang.String fileName)
                                                 throws java.io.FileNotFoundException
        Get the URL of a resource.
        Parameters:
        dir - the directory to read from
        fileName - the file name of the file to read
        Returns:
        the URL for reading from fileName
        Throws:
        java.io.FileNotFoundException - in case all tries getting a URL to the file failed
      • getFile

        @NotNull
        public static @NotNull java.io.File getFile​(@NotNull
                                                    @NotNull java.io.File dir,
                                                    @NotNull
                                                    @NotNull java.lang.String fileName)
                                             throws java.io.IOException
        Returns a File instance for a resource that is a regular file on the file system. Returns the passed file if it is a regular file. Otherwise copies the passed file into a temporary regular file and returns the copy.
        Parameters:
        dir - directory to read from
        fileName - file name of file to read
        Returns:
        the file
        Throws:
        java.io.IOException - if the file does not exist or cannot be copied to the file system
      • findPathFile

        @NotNull
        public static @NotNull java.io.File findPathFile​(@NotNull
                                                         @NotNull java.lang.String name)
                                                  throws java.io.IOException
        Searches for file on all paths specified by the environment variable "PATH".
        Parameters:
        name - the file to search for
        Returns:
        the matching file
        Throws:
        java.io.IOException - if the file was not found
      • getCanonicalPath

        @NotNull
        public static @NotNull java.lang.String getCanonicalPath​(@NotNull
                                                                 @NotNull java.io.File file)
        Calls File.getCanonicalPath(). If this fails, returns File.getAbsolutePath().
        Parameters:
        file - the file
        Returns:
        the absolute path
      • getCanonicalFile

        @NotNull
        public static @NotNull java.io.File getCanonicalFile​(@NotNull
                                                             @NotNull java.io.File file)
        Calls File.getCanonicalFile(). If this fails, returns File.getAbsoluteFile().
        Parameters:
        file - the file
        Returns:
        the absolute path