/*
* Created on 2004/08/09
* Author aki@www.xucker.jpn.org
* License Apache2.0 or Common Public License
*/
package org.jpn.xucker.commons.util;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
/**
*
*
*/
public class IOClassLoader extends ClassLoader{
public Class loadClass(File file){
try {
return loadClass(new FileInputStream(file));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
public Class loadClass(InputStream input){
Class c=null;
try {
byte[] classbyte=IOUtils.toByteArray(input);
c=defineClass(classbyte,0,classbyte.length);
}catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch(IllegalAccessError e){
e.printStackTrace();
}
return c;
}
}
|