public class FileUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
appendLines(File file,
Collection<String> lines) |
static void |
copy(String src,
String dst) |
static String |
createTempFileWithLines(String suffix,
Iterable<String> lines)
Create a temporary file (see
File.createTempFile(String, String) ) and fill it with the given lines. |
static File |
extractFromResource(String name)
Helper method for extracting a given resource to File
|
static Collection<File> |
getClasses(File root) |
static void |
purgeTemps() |
static Collection<String> |
readAllLines(File file) |
static Collection<String> |
readAllLines(InputStream stream) |
static Collection<String> |
readAllLines(Reader src) |
static <T extends Closeable> |
safelyClose(T obj) |
static <T extends Flushable & Closeable> |
safelyClose(T obj) |
static Collection<String> |
tail(File file,
int num) |
static File |
tempFile(String suffix)
Creates the temp file with given suffix.
|
static void |
touch(String f) |
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) |
public static TempFile weakTempFile(String suffix) throws IOException
suffix
- suffixIOException
- if things go crazypublic static void purgeTemps()
public static File tempFile(String suffix) throws IOException
suffix
- suffixIOException
- if things go crazypublic static File extractFromResource(String name) throws IOException
name
- name of the resourceIOException
- if things go crazypublic static String createTempFileWithLines(String suffix, Iterable<String> lines) throws IOException
File.createTempFile(String, String)
) and fill it with the given lines.suffix
- file suffix File.createTempFile(String, String)
lines
- to be writtenIOException
- on file creation errorpublic static Collection<String> tail(File file, int num) throws IOException
IOException
public static Collection<String> readAllLines(Reader src) throws IOException
IOException
public static Collection<String> readAllLines(File file) throws IOException
IOException
public static Collection<String> readAllLines(InputStream stream) throws IOException
IOException
public static void writeLines(File file, Collection<String> lines) throws IOException
IOException
public static void appendLines(File file, Collection<String> lines) throws IOException
IOException
public static Collection<File> getClasses(File root)
public static void copy(String src, String dst) throws IOException
IOException
public static <T extends Closeable> void safelyClose(T obj)
public static void touch(String f) throws IOException
IOException
Copyright © 2012–2020 Oracle. All rights reserved.