| java.lang.Object com.ecyrd.jspwiki.FileUtil
FileUtil | final public class FileUtil (Code) | | Generic utilities related to file and stream handling.
|
Method Summary | |
public static void | copyContents(Reader in, Writer out) Just copies all characters from in to out. | public static void | copyContents(InputStream in, OutputStream out) Just copies all bytes from in to out. | public static String | getThrowingMethod(Throwable t) Returns the class and method name (+a line number) in which the
Throwable was thrown.
Parameters: t - A Throwable to analyze. | public static File | newTmpFile(String content, String encoding) Makes a new temporary file and writes content into it. | public static File | newTmpFile(String content) Creates a new temporary file using the default encoding
of ISO-8859-1 (Latin1).
Parameters: content - The content to put into the file. throws: IOException - If writing was unsuccessful. | public static String | readContents(InputStream input, String encoding) Reads in file contents.
This method is smart and falls back to ISO-8859-1 if the input stream does not
seem to be in the specified encoding.
Parameters: input - The InputStream to read from. Parameters: encoding - The encoding to assume at first. | public static String | readContents(Reader in) Returns the full contents of the Reader as a String.
since: 1.5.8 Parameters: in - The reader from which the contents shall be read. | public static String | runSimpleCommand(String command, String directory) Runs a simple command in given directory.
The environment is inherited from the parent process (e.g. |
copyContents | public static void copyContents(Reader in, Writer out) throws IOException(Code) | | Just copies all characters from in to out. The copying
is performed using a buffer of bytes.
since: 1.5.8 Parameters: in - The reader to copy from Parameters: out - The reader to copy to throws: IOException - If reading or writing failed. |
copyContents | public static void copyContents(InputStream in, OutputStream out) throws IOException(Code) | | Just copies all bytes from in to out. The copying is
performed using a buffer of bytes.
since: 1.9.31 Parameters: in - The inputstream to copy from Parameters: out - The outputstream to copy to throws: IOException - In case reading or writing fails. |
getThrowingMethod | public static String getThrowingMethod(Throwable t)(Code) | | Returns the class and method name (+a line number) in which the
Throwable was thrown.
Parameters: t - A Throwable to analyze. A human-readable string stating the class and method. Do not relythe format to be anything fixed. |
newTmpFile | public static File newTmpFile(String content, String encoding) throws IOException(Code) | | Makes a new temporary file and writes content into it. The temporary
file is created using File.createTempFile() , and the usual
semantics apply. The files are not deleted automatically in exit.
Parameters: content - Initial content of the temporary file. Parameters: encoding - Encoding to use. The handle to the new temporary file throws: IOException - If the content creation failed. See Also: java.io.File.createTempFile(StringStringFile) |
readContents | public static String readContents(InputStream input, String encoding) throws IOException(Code) | | Reads in file contents.
This method is smart and falls back to ISO-8859-1 if the input stream does not
seem to be in the specified encoding.
Parameters: input - The InputStream to read from. Parameters: encoding - The encoding to assume at first. A String, interpreted in the "encoding", or, if it fails, in Latin1. throws: IOException - If the stream cannot be read or the stream cannot bedecoded (even) in Latin1 |
readContents | public static String readContents(Reader in) throws IOException(Code) | | Returns the full contents of the Reader as a String.
since: 1.5.8 Parameters: in - The reader from which the contents shall be read. String read from the Reader throws: IOException - If reading fails. |
runSimpleCommand | public static String runSimpleCommand(String command, String directory) throws IOException, InterruptedException(Code) | | Runs a simple command in given directory.
The environment is inherited from the parent process (e.g. the
one in which this Java VM runs).
Standard output from the command. Parameters: command - The command to run Parameters: directory - The working directory to run the command in throws: IOException - If the command failed throws: InterruptedException - If the command was halted |
|
|