diff options
Diffstat (limited to 'java/org/brotli/dec/Utils.java')
-rw-r--r-- | java/org/brotli/dec/Utils.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/java/org/brotli/dec/Utils.java b/java/org/brotli/dec/Utils.java index 369e655..1583c75 100644 --- a/java/org/brotli/dec/Utils.java +++ b/java/org/brotli/dec/Utils.java @@ -8,6 +8,8 @@ package org.brotli.dec; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.Buffer; /** * A set of utility methods. @@ -71,4 +73,19 @@ final class Utils { static void closeInput(InputStream src) throws IOException { src.close(); } + + static byte[] toUsAsciiBytes(String src) { + try { + // NB: String#getBytes(String) is present in JDK 1.1, while other variants require JDK 1.6 and + // above. + return src.getBytes("US-ASCII"); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); // cannot happen + } + } + + // Crazy pills factory: code compiled for JDK8 does not work on JRE9. + static void flipBuffer(Buffer buffer) { + buffer.flip(); + } } |