blob: 939e1fff501df2cd0765f588be70f65853366233 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
package org.zwobble.mammoth.internal.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.Base64;
import static org.zwobble.mammoth.internal.util.Streams.toByteArray;
public class Base64Encoding {
public static String streamToBase64(SupplierWithException<InputStream, IOException> open) throws IOException {
try (InputStream stream = open.get()) {
return Base64Encoding.streamToBase64(stream);
}
}
public static String streamToBase64(InputStream stream) throws IOException {
return Base64.getEncoder().encodeToString(toByteArray(stream));
}
}
|