Package es.kukenan.smartfi.common.utils
Class IoUtils
java.lang.Object
es.kukenan.smartfi.common.utils.IoUtils
Input/Output utils.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]Fully read the given file and return its bytes.static byte[]read(InputStream is) Fully read the given stream and return its bytes.static StringFully read the given stream and return its bytes as a String.static booleansafeCleanUp(Path path) Safely cleanup the given path.static voidstore(InputStream is, File file) Store the given input stream as the given file contents.static inttransfer(InputStream is, OutputStream os) Fully transfer the given stream to the given output stream and return the transferred byte count.
-
Field Details
-
CHARSET
Default charset.- See Also:
-
BUF_SIZE
public static final int BUF_SIZEDefault size for buffers used in this class.- See Also:
-
-
Constructor Details
-
IoUtils
private IoUtils()Hide constructor.
-
-
Method Details
-
read
Fully read the given stream and return its bytes.- Parameters:
is- the stream to read from.- Returns:
- the bytes read.
- Throws:
IOException- if anyIOExceptionis thrown during the process.
-
read
Fully read the given file and return its bytes.- Parameters:
file- the file to read from.- Returns:
- the bytes read.
- Throws:
IOException- if anyIOExceptionis thrown during the process.
-
transfer
Fully transfer the given stream to the given output stream and return the transferred byte count.- Parameters:
is- the stream to read from.os- the stream to write to.- Returns:
- the transferred byte count.
- Throws:
IOException- if anyIOExceptionis thrown during the process.
-
readString
Fully read the given stream and return its bytes as a String.- Parameters:
is- the stream to read from.- Returns:
- the string created from the bytes read.
- Throws:
IOException- if anyIOExceptionis thrown during the process.
-
store
Store the given input stream as the given file contents.- Parameters:
is- data stream to store.file- the file where to store de data.- Throws:
IOException- if anyIOExceptionis thrown during the process.
-
safeCleanUp
Safely cleanup the given path. (If an error occurs the method will not fail but return false).- Parameters:
path- the directory to delete.- Returns:
- true if no error caught, false in other case.
-