⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classinstall.java

📁 java 到c的转换程序的原代码.对喜欢C程序而不懂JAVA程序的人很有帮助
💻 JAVA
字号:
//  ClassInstall.java -- for copying class files into a package directorypackage toba.translator;import toba.classfile.ClassFile;import java.io.*;public class ClassInstall {public static void mkdir(String name)     throws IOException{    name = name.replace('/', File.separatorChar);    File f = new File(name);    if (!f.isDirectory() && !f.mkdirs())	throw new IOException("Could not make directory " + name);}public static void copy(DataInputStream src, String destname)        throws IOException{    int len;    byte[] buf = new byte[4096];    boolean okToIgnoreEOFE;    okToIgnoreEOFE = false;    try {        destname = destname.replace('/', File.separatorChar);        FileOutputStream dest = new FileOutputStream(destname);        okToIgnoreEOFE = true;        while (true) {            len = src.read(buf);            if (len <= 0)                break;            dest.write(buf, 0, len);        }        okToIgnoreEOFE = false;        dest.close ();    } catch (EOFException e) {        /* Under Irix with jdk 1.1.5, extracting certain classes from         * rt.jar seems to throw the following exception _during_the_write_         * of the uncompressed class file.  Checking one or two of the         * classes indicates that the write actually does complete, so         * we'll ignore that exception. */        if (! (okToIgnoreEOFE &&               e.toString().equals ("java.io.EOFException: Unexpected end of ZLIB input stream"))) {            throw e;        }    }}public static void install(String findname, String classname, String target)    throws IOException, ClassNotFoundException{    // Make sure the target exists; then make sure it's a directory.    // Some bad assumptions here about what we're given as target.    if (0 < target.length ()) {        mkdir (target);    }    target += File.separatorChar;    // Get a handle for reading the class file    ClassFile f = ClassFile.find(findname);    // turn class name into a filename    String filename = classname;    if (! filename.endsWith (".class")) {        filename = filename.replace('.', '/') + ".class";    }    // copy it into place    int index = filename.lastIndexOf('/');    if (index > 0) {	String dir = filename.substring(0, index);	mkdir(target + dir);    }    copy(f, target + filename);    f.close();}} // class ClassInstall

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -