Class TestFileUtils
java.lang.Object
org.eclipse.aether.internal.test.util.TestFileUtils
Provides utility methods to read and write (temporary) files.
-
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic FileDeprecated.static FilecreateTempDir(String suffix) Deprecated.use the JUnit 5@TempDirextension insteadstatic FilecreateTempFile(byte[] pattern, int repeat) Deprecated.use the JUnit 5@TempDirextension insteadstatic FilecreateTempFile(String contents) Deprecated.use the JUnit 5@TempDirextension insteadstatic voiddeleteFile(File file) static voidDeprecated.use the JUnit 5@TempDirextension instead, which cleans up after itselfstatic booleanDeprecated.useFiles.createDirectories(Path)insteadstatic byte[]Deprecated.useFiles.readAllBytes(Path)insteadstatic voidreadProps(File file, Properties props) static StringreadString(File file) static voidwriteBytes(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(File file, Properties props) static voidwriteString(File file, String content) Deprecated.useFiles.write(Path, byte[])insteadstatic voidwriteString(File file, String content, long timestamp) Deprecated.useFiles.write(Path, byte[])andFiles.setLastModifiedTime(Path, FileTime)instead
-
Method Details
-
deleteTempFiles
Deprecated.use the JUnit 5@TempDirextension instead, which cleans up after itselfDeletes the files created by the temp-file helpers of this class.- Throws:
IOException- if an I/O error occurs
-
deleteFile
- Throws:
IOException
-
mkdirs
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.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:
IOException- if an I/O error occurs
-
createTempFile
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:
IOException- if an I/O error occurs
-
createTempDir
Deprecated.use the JUnit 5@TempDirextension insteadCreates a temporary directory.- Returns:
- the temporary directory
- Throws:
IOException- if an I/O error occurs
-
createTempDir
Deprecated.use the JUnit 5@TempDirextension insteadCreates a temporary directory.- Returns:
- the temporary directory
- Throws:
IOException- if an I/O error occurs
-
copyFile
- Throws:
IOException
-
readBytes
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:
IOException- if an I/O error occurs
-
writeBytes
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:
IOException- if an I/O error occurs
-
readString
- Throws:
IOException
-
writeString
Deprecated.useFiles.write(Path, byte[])insteadWrites a UTF-8 string to a file.- Parameters:
file- the file to writecontent- the content to write- Throws:
IOException- if an I/O error occurs
-
writeString
@Deprecated public static void writeString(File file, String content, long timestamp) throws 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:
IOException- if an I/O error occurs
-
readProps
- Throws:
IOException
-
writeProps
- Throws:
IOException
-
@TempDirextension instead