Class FileUtil


  • public abstract class FileUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String ESCAPED_NEWLINE  
      static java.lang.String FILE_SEP  
      static java.lang.String NEWLINE  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String read​(java.io.File file)  
      static java.lang.String readIfExists​(java.io.File file)  
      static java.lang.String resolve​(java.lang.String path, java.io.File parent)
      Returns the absolute path for the given path.
      static void write​(java.io.File file, java.lang.String contents)  
      static void write​(java.io.File file, java.lang.String contents, boolean append)  
      static void write​(java.lang.String path, java.lang.String contents)  
      static void write​(java.lang.String path, java.lang.String contents, boolean append)  
      • Methods inherited from class java.lang.Object

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

      • FILE_SEP

        public static final java.lang.String FILE_SEP
      • NEWLINE

        public static final java.lang.String NEWLINE
      • ESCAPED_NEWLINE

        public static final java.lang.String ESCAPED_NEWLINE
    • Method Detail

      • resolve

        public static java.lang.String resolve​(java.lang.String path,
                                               java.io.File parent)
        Returns the absolute path for the given path. The given path may be relative, in which case it is resolved using parent as its parent path. If parent is null, the path is resolved using the default relative path (typically the directory from which the JVM was launched).
        Parameters:
        path - a relative or absolute path.
        parent - the parent directory to use when resolving a relative path.
        Returns:
        The absolute path for the given path.
        Throws:
        java.lang.NullPointerException - when path is null
      • readIfExists

        public static java.lang.String readIfExists​(java.io.File file)
                                             throws java.io.IOException
        Returns:
        null if the file doesn't exist
        Throws:
        java.io.IOException
      • read

        public static java.lang.String read​(java.io.File file)
                                     throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write​(java.lang.String path,
                                 java.lang.String contents)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write​(java.lang.String path,
                                 java.lang.String contents,
                                 boolean append)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write​(java.io.File file,
                                 java.lang.String contents)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public static void write​(java.io.File file,
                                 java.lang.String contents,
                                 boolean append)
                          throws java.io.IOException
        Throws:
        java.io.IOException