Package org.greenrobot.essentials.io
Class IoUtils
java.lang.Object
org.greenrobot.essentials.io.IoUtils
Utils for dealing with IO (streams, readers, ...).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
copyAllBytes
(InputStream in, OutputStream out) Copies all available data from in to out without closing any stream.static byte[]
getDigest
(InputStream in, String digestAlgo) static String
getMd5
(InputStream in) static String
getSha1
(InputStream in) static String
getSha256
(InputStream in) static byte[]
static byte[]
static String
readAllChars
(Reader reader) static String
readAllCharsAndClose
(Reader reader) static void
Closes the given resource (e.g.static void
updateChecksum
(InputStream in, Checksum checksum) static void
writeAllCharsAndClose
(Writer writer, CharSequence text)
-
Field Details
-
BUFFER_SIZE
private static final int BUFFER_SIZE- See Also:
-
-
Constructor Details
-
IoUtils
public IoUtils()
-
-
Method Details
-
readAllBytes
- Throws:
IOException
-
readAllBytesAndClose
- Throws:
IOException
-
readAllChars
- Throws:
IOException
-
readAllCharsAndClose
- Throws:
IOException
-
writeAllCharsAndClose
- Throws:
IOException
-
updateChecksum
- Throws:
IOException
-
getMd5
- Returns:
- MD5 digest (32 hex characters).
- Throws:
IOException
-
getSha1
- Returns:
- SHA-1 digest (40 hex characters).
- Throws:
IOException
-
getSha256
- Returns:
- SHA-256 digest (64 hex characters).
- Throws:
IOException
-
getDigest
- Throws:
IOException
-
copyAllBytes
Copies all available data from in to out without closing any stream.- Returns:
- number of bytes copied
- Throws:
IOException
-
safeClose
Closes the given resource (e.g. stream, reader, writer, etc.) inside a try/catch. Does nothing if stream is null.
-