public class FileUtils extends Object
Modifier and Type | Method | 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 Collection<String> |
readAllLines(File file) |
|
static Collection<String> |
readAllLines(InputStream stream) |
|
static Collection<String> |
readAllLines(Reader src) |
|
static <T extends Flushable & Closeable> |
safelyClose(T obj) |
|
static Collection<String> |
tail(File file,
int num) |
|
static File |
tempFile(String suffix) |
|
static void |
touch(String f) |
|
static void |
writeLines(File file,
Collection<String> lines) |
public static File tempFile(String suffix) throws IOException
IOException
public 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-2016 Oracle. All Rights Reserved.