Package org.openjdk.jmh.util
Class FileUtils
java.lang.Object
org.openjdk.jmh.util.FileUtils
A utility class for File creation and manipulation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendLines(File file, Collection<String> lines) static voidstatic StringcreateTempFileWithLines(String suffix, Iterable<String> lines) Create a temporary file (seeFile.createTempFile(String, String)) and fill it with the given lines.static FileextractFromResource(String name) Helper method for extracting a given resource to Filestatic Collection<File>getClasses(File root) static voidstatic Collection<String>readAllLines(File file) static Collection<String>readAllLines(InputStream stream) static Collection<String>readAllLines(Reader src) safelyClose(T obj) static Collection<String>static FileCreates the temp file with given suffix.static voidstatic TempFileweakTempFile(String suffix) Creates the temp file, and retains it as long as the reference to it is reachable.static voidwriteLines(File file, Collection<String> lines)
-
Method Details
-
weakTempFile
Creates the temp file, and retains it as long as the reference to it is reachable.- Parameters:
suffix- suffix- Returns:
- temp file
- Throws:
IOException- if things go crazy
-
purgeTemps
public static void purgeTemps() -
tempFile
Creates the temp file with given suffix. The file would be removed on JVM exit, or when caller deletes the file itself.- Parameters:
suffix- suffix- Returns:
- temporary file
- Throws:
IOException- if things go crazy
-
extractFromResource
Helper method for extracting a given resource to File- Parameters:
name- name of the resource- Returns:
- a File pointing to the extracted resource
- Throws:
IOException- if things go crazy
-
createTempFileWithLines
public static String createTempFileWithLines(String suffix, Iterable<String> lines) throws IOException Create a temporary file (seeFile.createTempFile(String, String)) and fill it with the given lines.- Parameters:
suffix- file suffixFile.createTempFile(String, String)lines- to be written- Returns:
- the temporary file absolute path
- Throws:
IOException- on file creation error
-
tail
- Throws:
IOException
-
readAllLines
- Throws:
IOException
-
readAllLines
- Throws:
IOException
-
readAllLines
- Throws:
IOException
-
writeLines
- Throws:
IOException
-
appendLines
- Throws:
IOException
-
getClasses
-
copy
- Throws:
IOException
-
safelyClose
-
safelyClose
-
touch
- Throws:
IOException
-