Package io.hawt.util
Class IOHelper
- java.lang.Object
-
- io.hawt.util.IOHelper
-
public class IOHelper extends Object
A 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(Closeable closeable, String name, org.slf4j.Logger log)Closes the given resource if it is available, logging any closing exceptions to the given log.static voidcopy(InputStream is, OutputStream os)static intcopy(Reader input, Writer output)static intcopy(Reader input, Writer output, int bufferSize)static StringreadFully(BufferedReader reader)Reads the entire reader into memory as a Stringstatic StringreadFully(File file)static voidwrite(File file, byte[] data)static voidwrite(File file, byte[] data, boolean append)Writes the given data to the file; either in append mode or replace mode depending the append flagstatic voidwrite(File file, String text)Writes the text to the given file, overwriting the previous file if it existed.static voidwrite(File file, String text, boolean append)Writes the given text to the file; either in append mode or replace mode depending the append flag
-
-
-
Field Detail
-
BUFFER_SIZE
public static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
-
Method Detail
-
readFully
public static String readFully(File file) throws IOException
- Throws:
IOException
-
readFully
public static String readFully(BufferedReader reader) throws IOException
Reads the entire reader into memory as a String- Throws:
IOException
-
close
public static void close(Closeable closeable, 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(File file, String text) throws IOException
Writes the text to the given file, overwriting the previous file if it existed.- Throws:
IOException
-
write
public static void write(File file, byte[] data) throws IOException
- Throws:
IOException
-
write
public static void write(File file, String text, boolean append) throws IOException
Writes the given text to the file; either in append mode or replace mode depending the append flag- Throws:
IOException
-
write
public static void write(File file, byte[] data, boolean append) throws IOException
Writes the given data to the file; either in append mode or replace mode depending the append flag- Throws:
IOException
-
copy
public static int copy(Reader input, Writer output) throws IOException
- Throws:
IOException
-
copy
public static int copy(Reader input, Writer output, int bufferSize) throws IOException
- Throws:
IOException
-
copy
public static void copy(InputStream is, OutputStream os) throws IOException
- Throws:
IOException
-
-