All pastes #498573 Raw Edit

Unnamed

public java v1 · immutable
·published 2007-05-20 15:20 UTC
rendered paste body
public void loadHandlers() {		handlers.clear();		File f = new File("./modules/");		if (!f.exists()) { f.mkdirs(); }		File[] dirs = f.listFiles(new FileFilter() {			public boolean accept(File arg0) {				return arg0.isDirectory();			}					});		int i = 0;		for (File d : dirs) {			if ((d = new File(d.getPath() + "/Main.class")).exists()) {				try {					String path = d.getPath();					path = path.replaceAll("^[" + Pattern.quote(File.separator) + ".]+","").replace(".class","");					System.out.println(path.replace(File.separator, "."));					Class c = Class.forName(path.replace(File.separator, "."));					handlers.add((IRREventHandler)c.cast(new Object()));					i++;				} catch (ClassNotFoundException e) {					// TODO Auto-generated catch block					Logger.logError("Module error, not found");					Logger.log(e);					continue;				}			}			else { continue; }		}		Logger.logEvent("Loaded " + i + " modules.");	}