|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.rice.cs.util.FileOps
A class to provide some convenient file operations as static methods. It's abstract to prevent (useless) instantiation, though it can be subclassed to provide convenient namespace importation of its methods.
Constructor Summary | |
FileOps()
|
Method Summary | |
static File |
createTempDirectory(String name)
Create a new temporary directory. |
static File |
createTempDirectory(String name,
File parent)
Create a new temporary directory. |
static boolean |
deleteDirectory(File dir)
Delete the given directory including any files and directories it contains. |
static String |
readFileAsString(File file)
Read the entire contents of a file and return them. |
static byte[] |
readStreamAsBytes(InputStream stream)
Reads the stream until it reaches EOF, and then returns the read contents as a byte array. |
static void |
writeStringToFile(File file,
String text)
Writes text to the file. |
static File |
writeStringToNewTempFile(String prefix,
String suffix,
String text)
Creates a new temporary file and writes the given text to it. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
public FileOps()
Method Detail |
public static byte[] readStreamAsBytes(InputStream stream) throws IOException
stream
- Input stream to read.public static String readFileAsString(File file) throws IOException
public static File writeStringToNewTempFile(String prefix, String suffix, String text) throws IOException
prefix
- Beginning part of file name, before unique numbersuffix
- Ending part of file name, after unique numbertext
- Text to write to filepublic static void writeStringToFile(File file, String text) throws IOException
file
- File to write totext
- Text to writepublic static File createTempDirectory(String name) throws IOException
name
- Non-unique portion of the name of the directory to create.public static File createTempDirectory(String name, File parent) throws IOException
name
- Non-unique portion of the name of the directory to create.parent
- Parent directory to contain the new directorypublic static boolean deleteDirectory(File dir)
dir
- File object representing directory to delete. If, for some
reason, this file object is not a directory, it will still be
deleted.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |