|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ecyrd.jspwiki.FileUtil
public final class FileUtil
Generic utilities related to file and stream handling.
| Method Summary | |
|---|---|
static void |
copyContents(InputStream in,
OutputStream out)
Just copies all bytes from in to out. |
static void |
copyContents(Reader in,
Writer out)
Just copies all characters from in to out. |
static String |
getThrowingMethod(Throwable t)
Returns the class and method name (+a line number) in which the Throwable was thrown. |
static File |
newTmpFile(String content)
Creates a new temporary file using the default encoding of ISO-8859-1 (Latin1). |
static File |
newTmpFile(String content,
String encoding)
Makes a new temporary file and writes content into it. |
static String |
readContents(InputStream input,
String encoding)
Reads in file contents. |
static String |
readContents(Reader in)
Returns the full contents of the Reader as a String. |
static String |
runSimpleCommand(String command,
String directory)
Runs a simple command in given directory. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static File newTmpFile(String content,
String encoding)
throws IOException
File.createTempFile(), and the usual
semantics apply. The files are not deleted automatically in exit.
content - Initial content of the temporary file.encoding - Encoding to use.
IOException - If the content creation failed.File.createTempFile(String,String,File)
public static File newTmpFile(String content)
throws IOException
content - The content to put into the file.
IOException - If writing was unsuccessful.newTmpFile( String, String ),
File.createTempFile(String,String,File)
public static String runSimpleCommand(String command,
String directory)
throws IOException,
InterruptedException
command - The command to rundirectory - The working directory to run the command in
IOException - If the command failed
InterruptedException - If the command was halted
public static void copyContents(Reader in,
Writer out)
throws IOException
in - The reader to copy fromout - The reader to copy to
IOException - If reading or writing failed.
public static void copyContents(InputStream in,
OutputStream out)
throws IOException
in - The inputstream to copy fromout - The outputstream to copy to
IOException - In case reading or writing fails.
public static String readContents(InputStream input,
String encoding)
throws IOException
This method is smart and falls back to ISO-8859-1 if the input stream does not seem to be in the specified encoding.
input - The InputStream to read from.encoding - The encoding to assume at first.
IOException - If the stream cannot be read or the stream cannot be
decoded (even) in Latin1
public static String readContents(Reader in)
throws IOException
in - The reader from which the contents shall be read.
IOException - If reading fails.public static String getThrowingMethod(Throwable t)
t - A Throwable to analyze.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||