org.zeroturnaround.zip.ZTZipReflectionUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zt-zip Show documentation
Show all versions of zt-zip Show documentation
The project is intended to have a small, easy and fast library to process ZIP archives. Either create, modify or explode them. On disk or in memory.
package org.zeroturnaround.zip;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ZTZipReflectionUtil {
public static final String JAVA8_STREAM_API = "java.util.stream.Stream";
private ZTZipReflectionUtil() {
}
static Class extends T> getClassForName(String name, Class clazz) {
try {
return Class.forName(name).asSubclass(clazz);
}
catch (ClassNotFoundException e) {
throw new ZipException(e);
}
catch (ClassCastException e) {
throw new ZipException(e);
}
}
static Method getDeclaredMethod(Class> clazz, String methodName, Class>... parameterTypes) {
try {
return clazz.getDeclaredMethod(methodName, parameterTypes);
}
catch (NoSuchMethodException e) {
throw new ZipException(e);
}
}
static Object invoke(Method method, Object obj, Object... args) throws ZipException {
try {
return method.invoke(obj, args);
}
catch (IllegalAccessException e) {
throw new ZipException(e);
}
catch (InvocationTargetException e) {
throw new ZipException(e);
}
catch (IllegalArgumentException e) {
throw new ZipException(e);
}
}
public static boolean isClassAvailable(String className) {
try {
Class.forName(className);
return true;
}
catch (ClassNotFoundException e) {
// Ignore
}
catch (SecurityException e) {
// Ignore
}
return false;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy