minify-html/java/src/main/java/in/wilsonl/hyperbuild/Hyperbuild.java

24 lines
663 B
Java
Raw Normal View History

2020-01-17 23:19:38 -05:00
package in.wilsonl.hyperbuild;
import java.util.Arrays;
import static java.nio.charset.StandardCharsets.UTF_8;
public class Hyperbuild {
static {
String nativeLibPath = Hyperbuild.class.getResource("libhyperbuild_java.so").getPath();
System.load(nativeLibPath);
}
public static native int minifyInPlace(byte[] code) throws HyperbuildException;
public static byte[] minify(byte[] code) throws HyperbuildException {
int size = minifyInPlace(code);
return Arrays.copyOf(code, size);
}
public static String minify(String code) throws HyperbuildException {
return new String(Hyperbuild.minify(code.getBytes(UTF_8)), UTF_8);
}
}