/** * WebSocket */ package com.xiongyingqi.util; /** * @author η‘›ηͺ * @version 2013-8-7 δΈ‹εˆ3:30:03 */ import java.io.File; import java.io.FileInputStream; import java.io.InputStream; public class Test { @SuppressWarnings("unchecked") public static void main(String[] args) { try { MyClassLoader loader = new MyClassLoader(); File folder = new File("builder/classes"); if (folder.isDirectory()) { File[] fs = folder.listFiles(); byte[] bs = null; InputStream in = null; int length = 0; Class cls = null; for (File f : fs) { in = new FileInputStream(f); bs = new byte[in.available()]; length = in.read(bs); cls = loader.loadClass(null, bs, length); System.out.println(cls.newInstance()); } } } catch (Exception ex) { ex.printStackTrace(); } } }