Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.DataInputStream;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.lang.reflect.Method;
- import java.net.URL;
- import java.net.URLClassLoader;
- public class face {
- public static void main(String[] args) throws IOException,
- ClassNotFoundException {
- File f = new File("book.class");
- int count;
- byte[] buffer = new byte[1024];
- DataInputStream dis = new DataInputStream(new FileInputStream(f));
- StringBuilder all = new StringBuilder();
- while ((count = dis.read(buffer)) > 0) {
- all.append(buffer);
- }
- File b = new File("book.class");
- FileOutputStream fos = new FileOutputStream(b);
- DataOutputStream dos = new DataOutputStream(fos);
- dos.write(all.toString().getBytes());
- String absolutePath = b.getAbsolutePath();
- URL classs[] = { b.toURI().toURL() };
- URLClassLoader sysloader = new URLClassLoader(classs);
- Class sysclass = sysloader.loadClass("book");
- try {
- Method method = sysclass.getDeclaredMethod("go", null);
- method.setAccessible(true);
- method.invoke(new Object() {
- }, null);
- } catch (Throwable t) {
- t.printStackTrace();
- throw new IOException(
- "Error, could not add URL to system classloader");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement