Class TestFileUtils


  • public class TestFileUtils
    extends java.lang.Object
    Provides utility methods to read and write (temporary) files.
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static long copyFile​(java.io.File source, java.io.File target)  
      static java.io.File createTempDir()
      Deprecated.
      use @TempDir (JUnit 5) Or TemporaryFolder (JUnit 4) instead
      static java.io.File createTempDir​(java.lang.String suffix)
      Deprecated.
      use @TempDir (JUnit 5) or TemporaryFolder (JUnit 4) instead
      static java.io.File createTempFile​(byte[] pattern, int repeat)
      Deprecated.
      static java.io.File createTempFile​(java.lang.String contents)
      Deprecated.
      use @TempDir (JUnit 5) Or TemporaryFolder (JUnit 4) instead
      static void deleteFile​(java.io.File file)  
      static void deleteTempFiles()
      Deprecated.
      static boolean mkdirs​(java.io.File directory)
      Deprecated.
      static byte[] readBytes​(java.io.File file)
      Deprecated.
      use Files.readAllBytes(Path) instead
      static void readProps​(java.io.File file, java.util.Properties props)  
      static java.lang.String readString​(java.io.File file)  
      static void writeBytes​(java.io.File file, byte[] pattern, int repeat)
      Deprecated.
      static void writeProps​(java.io.File file, java.util.Properties props)  
      static void writeString​(java.io.File file, java.lang.String content)
      Deprecated.
      static void writeString​(java.io.File file, java.lang.String content, long timestamp)
      Deprecated.
      • Methods inherited from class java.lang.Object

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

      • deleteTempFiles

        @Deprecated
        public static void deleteTempFiles()
                                    throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • deleteFile

        public static void deleteFile​(java.io.File file)
                               throws java.io.IOException
        Throws:
        java.io.IOException
      • mkdirs

        @Deprecated
        public static boolean mkdirs​(java.io.File directory)
        Deprecated.
      • createTempFile

        @Deprecated
        public static java.io.File createTempFile​(java.lang.String contents)
                                           throws java.io.IOException
        Deprecated.
        use @TempDir (JUnit 5) Or TemporaryFolder (JUnit 4) instead
        Throws:
        java.io.IOException - if an I/O error occurs
      • createTempFile

        @Deprecated
        public static java.io.File createTempFile​(byte[] pattern,
                                                  int repeat)
                                           throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • createTempDir

        @Deprecated
        public static java.io.File createTempDir()
                                          throws java.io.IOException
        Deprecated.
        use @TempDir (JUnit 5) Or TemporaryFolder (JUnit 4) instead
        Creates a temporary directory.
        Returns:
        the temporary directory
        Throws:
        java.io.IOException - if an I/O error occurs
      • createTempDir

        @Deprecated
        public static java.io.File createTempDir​(java.lang.String suffix)
                                          throws java.io.IOException
        Deprecated.
        use @TempDir (JUnit 5) or TemporaryFolder (JUnit 4) instead
        Creates a temporary directory.
        Returns:
        the temporary directory
        Throws:
        java.io.IOException - if an I/O error occurs
      • copyFile

        public static long copyFile​(java.io.File source,
                                    java.io.File target)
                             throws java.io.IOException
        Throws:
        java.io.IOException
      • readBytes

        @Deprecated
        public static byte[] readBytes​(java.io.File file)
                                throws java.io.IOException
        Deprecated.
        use Files.readAllBytes(Path) instead
        Reads the contents of a file into a byte array.
        Parameters:
        file - the file to read
        Returns:
        the contents of the file as a byte array
        Throws:
        java.io.IOException - if an I/O error occurs
      • writeBytes

        @Deprecated
        public static void writeBytes​(java.io.File file,
                                      byte[] pattern,
                                      int repeat)
                               throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readString

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

        @Deprecated
        public static void writeString​(java.io.File file,
                                       java.lang.String content)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • writeString

        @Deprecated
        public static void writeString​(java.io.File file,
                                       java.lang.String content,
                                       long timestamp)
                                throws java.io.IOException
        Deprecated.
        Throws:
        java.io.IOException
      • readProps

        public static void readProps​(java.io.File file,
                                     java.util.Properties props)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • writeProps

        public static void writeProps​(java.io.File file,
                                      java.util.Properties props)
                               throws java.io.IOException
        Throws:
        java.io.IOException