📄 systemclassloader.java~3~
字号:
package AM.vm_impl.util;/** * Created by IntelliJ IDEA. User: yellowicq Date: 2004-4-27 Time: 13:16:40 * To change this template use File | Settings | File Templates. */import java.io.*;public class GreeterClassLoader extends ClassLoader { // basePath gives the path to which this class // loader appends "/<typename>.class" to get the // full path name of the class file to load private String basePath; public GreeterClassLoader(String basePath) { this.basePath = basePath; } public GreeterClassLoader(ClassLoader parent, String basePath) { super(parent); this.basePath = basePath; } protected Class findClass(String className) throws ClassNotFoundException { byte classData[]; // Try to load it from the basePath directory. classData = getTypeFromBasePath(className); if (classData == null) { throw new ClassNotFoundException(); } // Parse it return defineClass(className, classData, 0, classData.length); } private byte[] getTypeFromBasePath(String typeName) { FileInputStream fis; String fileName = basePath + File.separatorChar + typeName.replace('.', File.separatorChar) + ".class"; try { fis = new FileInputStream(fileName); } catch (FileNotFoundException e) { return null; } BufferedInputStream bis = new BufferedInputStream(fis); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { int c = bis.read(); while (c != -1) { out.write(c); c = bis.read(); } } catch (IOException e) { return null; } return out.toByteArray(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -