Package io.hawt.util
Class IOHelper
- java.lang.Object
-
- io.hawt.util.IOHelper
-
public class IOHelper extends java.lang.ObjectA collection of IO helpers
-
-
Field Summary
Fields Modifier and Type Field Description static intBUFFER_SIZE
-
Constructor Summary
Constructors Constructor Description IOHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(java.io.Closeable closeable, java.lang.String name, org.slf4j.Logger log)Closes the given resource if it is available, logging any closing exceptions to the given log.static voidcopy(java.io.InputStream is, java.io.OutputStream os)static intcopy(java.io.Reader input, java.io.Writer output)static intcopy(java.io.Reader input, java.io.Writer output, int bufferSize)static java.lang.StringreadFully(java.io.BufferedReader reader)Reads the entire reader into memory as a Stringstatic java.lang.StringreadFully(java.io.File file)static voidwrite(java.io.File file, byte[] data)static voidwrite(java.io.File file, byte[] data, boolean append)Writes the given data to the file; either in append mode or replace mode depending on the append flag.static voidwrite(java.io.File file, java.lang.String text)Writes the text to the given file, overwriting the previous file if it existed.static voidwrite(java.io.File file, java.lang.String text, boolean append)Writes the given text to the file; either in append mode or replace mode depending on the append flag.
-
-
-
Field Detail
-
BUFFER_SIZE
public static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
readFully
public static java.lang.String readFully(java.io.File file) throws java.io.IOException- Throws:
java.io.IOException
-
readFully
public static java.lang.String readFully(java.io.BufferedReader reader) throws java.io.IOExceptionReads the entire reader into memory as a String- Throws:
java.io.IOException
-
close
public static void close(java.io.Closeable closeable, java.lang.String name, org.slf4j.Logger log)Closes the given resource if it is available, logging any closing exceptions to the given log.- Parameters:
closeable- the object to closename- the name of the resourcelog- the log to use when reporting closure warnings, will use this class's ownLoggerif log == null
-
write
public static void write(java.io.File file, java.lang.String text) throws java.io.IOExceptionWrites the text to the given file, overwriting the previous file if it existed.- Throws:
java.io.IOException
-
write
public static void write(java.io.File file, byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
write
public static void write(java.io.File file, java.lang.String text, boolean append) throws java.io.IOExceptionWrites the given text to the file; either in append mode or replace mode depending on the append flag.- Throws:
java.io.IOException
-
write
public static void write(java.io.File file, byte[] data, boolean append) throws java.io.IOExceptionWrites the given data to the file; either in append mode or replace mode depending on the append flag.- Throws:
java.io.IOException
-
copy
public static int copy(java.io.Reader input, java.io.Writer output) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static int copy(java.io.Reader input, java.io.Writer output, int bufferSize) throws java.io.IOException- Throws:
java.io.IOException
-
copy
public static void copy(java.io.InputStream is, java.io.OutputStream os) throws java.io.IOException- Throws:
java.io.IOException
-
-