bsp; while (-1 != (ch = is.read())) {
baos.write(ch);
}
data = baos.toByteArray();
}
catch (FileNotFoundException e) {
// e.printStackTrace();
return null;
}
catch (IOException ioe) {
ioe.printStackTrace();
}
finally {
try {
is.close();
baos.close();
}
catch (Exception e2) {
}
}
return data;
}
public static void main(String[] args) throws Exception {
//假定的系统加载器
MyClassLoader father = new MyClassLoader("father");
father.setPath(HOME + "syslib\\");
MyClassLoader child = new MyClassLoader(father, "child");
child.setPath(HOME + "ext\\");
MyClassLoader user = new MyClassLoader("user");
user.setPath(HOME + "usr\\");
System.out.println("-------------test parent--------------");
//测试父加载器关系
traverseParent(child);
System.out.println("-------------test load begin from child--------------");
//测试加载
test(child);
//测试命名空间
System.out.println("-------------test namespace--------------");
testNameSpace(user);
}
public static void traverseParent(ClassLoa |