Package org.openjdk.jmh.util
Class FileUtils
java.lang.Object
org.openjdk.jmh.util.FileUtils
A utility class for File creation and manipulation.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendLines
(File file, Collection<String> lines) static void
static String
createTempFileWithLines
(String suffix, Iterable<String> lines) Create a temporary file (seeFile.createTempFile(String, String)
) and fill it with the given lines.static File
extractFromResource
(String name) Helper method for extracting a given resource to Filestatic Collection
<File> getClasses
(File root) static void
static Collection
<String> readAllLines
(File file) static Collection
<String> readAllLines
(InputStream stream) static Collection
<String> readAllLines
(Reader src) safelyClose
(T obj) static Collection
<String> static File
Creates the temp file with given suffix.static void
static TempFile
weakTempFile
(String suffix) Creates the temp file, and retains it as long as the reference to it is reachable.static void
writeLines
(File file, Collection<String> lines)
-
Field Details
-
TEMP_FILE_MANAGER
-
-
Constructor Details
-
FileUtils
private FileUtils()
-
-
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
-