Package net.sf.jnati
Class FileUtils
- java.lang.Object
-
- net.sf.jnati.FileUtils
-
public class FileUtils extends java.lang.Object- Author:
- Sam Adams
-
-
Constructor Summary
Constructors Constructor Description FileUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyStreamToStream(java.io.InputStream in, java.io.OutputStream out)Copys the entire contents of an InputStream to an OutputStream.static booleandelTree(java.io.File dir)Deletes a directory and its contents.static java.io.FilegetTmpDir()Creates a temporary directory in the default system location.static java.io.FilegetTmpDir(java.io.File root)Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.static java.io.FilegetTmpDir(java.lang.String path)Creates a temporary directory in the specified location, or the default system location if the specified location is set to null.static byte[]readBytes(java.io.InputStream in)Reads the entire contents of an InputStream into an array of bytes.static java.lang.StringreadString(java.io.Reader in)Reads entire contents of reader into a string.static voidwriteStreamToFile(java.io.InputStream in, java.io.File file)Writes the contents of an input stream to a file.static voidwriteString(java.io.File file, java.lang.String string)Writes the contents of a string to a file.
-
-
-
Method Detail
-
getTmpDir
public static java.io.File getTmpDir() throws java.io.IOExceptionCreates a temporary directory in the default system location.- Returns:
- Throws:
java.io.IOException
-
getTmpDir
public static java.io.File getTmpDir(java.lang.String path) throws java.io.IOExceptionCreates a temporary directory in the specified location, or the default system location if the specified location is set to null.- Parameters:
path-- Returns:
- Throws:
java.io.IOException
-
getTmpDir
public static java.io.File getTmpDir(java.io.File root) throws java.io.IOExceptionCreates a temporary directory in the specified location, or the default system location if the specified location is set to null.- Parameters:
path-- Returns:
- Throws:
java.io.IOException
-
delTree
public static boolean delTree(java.io.File dir)
Deletes a directory and its contents.- Parameters:
dir-- Returns:
- True on success, false on failure.
-
writeStreamToFile
public static void writeStreamToFile(java.io.InputStream in, java.io.File file) throws java.io.IOExceptionWrites the contents of an input stream to a file. If the file already exists, it will be overwritten.- Parameters:
in- Input stream providing file contentsfile- File to write to- Throws:
java.io.IOException
-
copyStreamToStream
public static void copyStreamToStream(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOExceptionCopys the entire contents of an InputStream to an OutputStream.- Parameters:
in-out-- Throws:
java.io.IOException
-
readBytes
public static byte[] readBytes(java.io.InputStream in) throws java.io.IOExceptionReads the entire contents of an InputStream into an array of bytes.- Parameters:
in-- Returns:
- Throws:
java.io.IOException
-
readString
public static java.lang.String readString(java.io.Reader in) throws java.io.IOExceptionReads entire contents of reader into a string.- Parameters:
in-- Returns:
- Throws:
java.io.IOException
-
writeString
public static void writeString(java.io.File file, java.lang.String string) throws java.io.IOExceptionWrites the contents of a string to a file. If the file already exists it is over-written.- Parameters:
file-string-- Throws:
java.io.IOException
-
-