Package net.mtrop.doom.struct.io
Class IOUtils
java.lang.Object
net.mtrop.doom.struct.io.IOUtils
I/O utils.
- Author:
- Matthew Tropiano
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Attempts to close anAutoCloseable
object.static int
relay
(InputStream in, OutputStream out) Reads from an input stream, reading in a consistent set of data and writing it to the output stream.static int
relay
(InputStream in, OutputStream out, int maxLength) Reads from an input stream, reading in a consistent set of data and writing it to the output stream.
-
Method Details
-
relay
Reads from an input stream, reading in a consistent set of data and writing it to the output stream. The read/write is buffered so that it does not bog down the OS's other I/O requests. This method finishes when the end of the source stream is reached. Note that this may block if the input stream is a type of stream that will block if the input stream blocks for additional input. This method is thread-safe.- Parameters:
in
- the input stream to grab data from.out
- the output stream to write the data to.- Returns:
- the total amount of bytes relayed.
- Throws:
IOException
- if a read or write error occurs.
-
relay
Reads from an input stream, reading in a consistent set of data and writing it to the output stream. The read/write is buffered so that it does not bog down the OS's other I/O requests. This method finishes when the end of the source stream is reached. Note that this may block if the input stream is a type of stream that will block if the input stream blocks for additional input. This method is thread-safe.- Parameters:
in
- the input stream to grab data from.out
- the output stream to write the data to.maxLength
- the maximum amount of bytes to relay, or a value < 0 for no max.- Returns:
- the total amount of bytes relayed.
- Throws:
IOException
- if a read or write error occurs.
-
close
Attempts to close anAutoCloseable
object. If the object is null, this does nothing.- Parameters:
c
- the reference to the AutoCloseable object.
-