Class TestFileUtils
- java.lang.Object
-
- org.eclipse.aether.internal.test.util.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 longcopyFile(java.io.File source, java.io.File target)static java.io.FilecreateTempDir()Deprecated.use the JUnit 5@TempDirextension insteadstatic java.io.FilecreateTempDir(java.lang.String suffix)Deprecated.use the JUnit 5@TempDirextension insteadstatic java.io.FilecreateTempFile(byte[] pattern, int repeat)Deprecated.use the JUnit 5@TempDirextension insteadstatic java.io.FilecreateTempFile(java.lang.String contents)Deprecated.use the JUnit 5@TempDirextension insteadstatic voiddeleteFile(java.io.File file)static voiddeleteTempFiles()Deprecated.use the JUnit 5@TempDirextension instead, which cleans up after itselfstatic booleanmkdirs(java.io.File directory)Deprecated.useFiles.createDirectories(Path)insteadstatic byte[]readBytes(java.io.File file)Deprecated.useFiles.readAllBytes(Path)insteadstatic voidreadProps(java.io.File file, java.util.Properties props)static java.lang.StringreadString(java.io.File file)static voidwriteBytes(java.io.File file, byte[] pattern, int repeat)Deprecated.useFiles.write(Path, byte[])instead; it writes the array once, so forrepeat > 1build the repeated bytes firststatic voidwriteProps(java.io.File file, java.util.Properties props)static voidwriteString(java.io.File file, java.lang.String content)Deprecated.useFiles.write(Path, byte[])insteadstatic voidwriteString(java.io.File file, java.lang.String content, long timestamp)Deprecated.useFiles.write(Path, byte[])andFiles.setLastModifiedTime(Path, FileTime)instead
-
-
-
Method Detail
-
deleteTempFiles
@Deprecated public static void deleteTempFiles() throws java.io.IOException
Deprecated.use the JUnit 5@TempDirextension instead, which cleans up after itselfDeletes the files created by the temp-file helpers of this class.- Throws:
java.io.IOException- if an I/O error occurs
-
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.useFiles.createDirectories(Path)insteadCreates a directory and its missing parents.- Parameters:
directory- the directory to create- Returns:
trueif the directory exists afterwards
-
createTempFile
@Deprecated public static java.io.File createTempFile(java.lang.String contents) throws java.io.IOException
Deprecated.use the JUnit 5@TempDirextension insteadCreates a temporary file with the given UTF-8 content.- Parameters:
contents- the content to write- Returns:
- the temporary file
- 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.use the JUnit 5@TempDirextension insteadCreates a temporary file holding the byte pattern the given number of times.- Parameters:
pattern- the bytes to repeatrepeat- how many times the pattern is written- Returns:
- the temporary file
- Throws:
java.io.IOException- if an I/O error occurs
-
createTempDir
@Deprecated public static java.io.File createTempDir() throws java.io.IOException
Deprecated.use the JUnit 5@TempDirextension insteadCreates 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 the JUnit 5@TempDirextension insteadCreates 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.useFiles.readAllBytes(Path)insteadReads 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.useFiles.write(Path, byte[])instead; it writes the array once, so forrepeat > 1build the repeated bytes firstWrites a byte pattern to a file the given number of times.- Parameters:
file- the file to writepattern- the bytes to repeatrepeat- how many times the pattern is written- Throws:
java.io.IOException- if an I/O error occurs
-
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.useFiles.write(Path, byte[])insteadWrites a UTF-8 string to a file.- Parameters:
file- the file to writecontent- the content to write- Throws:
java.io.IOException- if an I/O error occurs
-
writeString
@Deprecated public static void writeString(java.io.File file, java.lang.String content, long timestamp) throws java.io.IOException
Deprecated.useFiles.write(Path, byte[])andFiles.setLastModifiedTime(Path, FileTime)insteadWrites a UTF-8 string to a file and sets its last-modified time.- Parameters:
file- the file to writecontent- the content to writetimestamp- the last-modified time to set, in milliseconds since the epoch- Throws:
java.io.IOException- if an I/O error occurs
-
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
-
-