Package com.redwood.scheduler.api.io
Class IOCloser
- java.lang.Object
-
- com.redwood.scheduler.api.io.IOCloser
-
public final class IOCloser extends Object
Utility class for IO to close and flush resources in the java.io and java.net packages:- java.io:
InputStream
,OutputStream
,Reader
,Writer
. - java.net:
Socket
.
- java.io:
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
close(InputStream toClose)
Close given input stream.static void
close(InputStream toClose, Logger log)
Close given input stream.static void
close(OutputStream toClose)
Close given output stream.static void
close(OutputStream toClose, Logger log)
Close given output stream.static void
close(Reader toClose)
Close given reader.static void
close(Reader toClose, Logger log)
Close given reader.static void
close(Writer toClose)
Close given writer.static void
close(Writer toClose, Logger log)
Close given writer.static void
close(Socket toClose)
Close given socket.static void
close(Socket toClose, Logger log)
Close given Socket.static void
flush(OutputStream toFlush)
Flushes given output stream.static void
flush(OutputStream toFlush, Logger log)
Flushes given output stream.static void
flush(Writer toFlush)
Flushes given writer.static void
flush(Writer toFlush, Logger log)
Flushes given writer.
-
-
-
Method Detail
-
close
public static void close(InputStream toClose)
Close given input stream. If stream is null does nothing.- Parameters:
toClose
- Stream to close
-
close
public static void close(InputStream toClose, Logger log)
Close given input stream. If stream is null does nothing. If closing of the stream fails, logs it to given logger.- Parameters:
toClose
- Stream to closelog
- Logger used when closing fails
-
close
public static void close(OutputStream toClose)
Close given output stream. If stream is null does nothing.- Parameters:
toClose
- Stream to close
-
close
public static void close(OutputStream toClose, Logger log)
Close given output stream. If stream is null does nothing. If closing of the stream fails, logs it to given logger.- Parameters:
toClose
- Stream to closelog
- Logger used when closing fails
-
close
public static void close(Reader toClose)
Close given reader. If reader is null does nothing.- Parameters:
toClose
- Reader to close
-
close
public static void close(Reader toClose, Logger log)
Close given reader. If reader is null does nothing. If closing of the reader fails, logs it to given logger.- Parameters:
toClose
- Reader to closelog
- Logger used when closing fails
-
close
public static void close(Writer toClose)
Close given writer. If writer is null does nothing.- Parameters:
toClose
- Writer to close
-
close
public static void close(Writer toClose, Logger log)
Close given writer. If writer is null does nothing. If closing of the writer fails, logs it to given logger.- Parameters:
toClose
- Writer to closelog
- Logger used when closing fails
-
close
public static void close(Socket toClose)
Close given socket. If socket is null does nothing.- Parameters:
toClose
- Writer to close
-
close
public static void close(Socket toClose, Logger log)
Close given Socket. If socket is null does nothing. If closing of the socket fails, logs it to given logger.- Parameters:
toClose
- Socket to closelog
- Logger used when closing fails
-
flush
public static void flush(Writer toFlush)
Flushes given writer. If writer is null does nothing.- Parameters:
toFlush
- Writer to flush
-
flush
public static void flush(Writer toFlush, Logger log)
Flushes given writer. If writer is null does nothing. If flushing of the writer fails, logs it to given logger.- Parameters:
toFlush
- Writer to flushlog
- Logger used when flushing fails
-
flush
public static void flush(OutputStream toFlush)
Flushes given output stream. If stream is null does nothing.- Parameters:
toFlush
- Output stream to flush
-
flush
public static void flush(OutputStream toFlush, Logger log)
Flushes given output stream. If stream is null does nothing. If flushing of the stream fails, logs it to given logger.- Parameters:
toFlush
- Stream to flushlog
- Logger used when flushing fails
-
-