當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassFile.write方法代碼示例

本文整理匯總了Java中javassist.bytecode.ClassFile.write方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassFile.write方法的具體用法?Java ClassFile.write怎麽用?Java ClassFile.write使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javassist.bytecode.ClassFile的用法示例。


在下文中一共展示了ClassFile.write方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeFile0

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
private static void writeFile0(ClassFile cf, String directoryName)
        throws CannotCompileException, IOException {
    String classname = cf.getName();
    String filename = directoryName + File.separatorChar
            + classname.replace('.', File.separatorChar) + ".class";
    int pos = filename.lastIndexOf(File.separatorChar);
    if (pos > 0) {
        String dir = filename.substring(0, pos);
        if (!dir.equals("."))
            new File(dir).mkdirs();
    }

    DataOutputStream out = new DataOutputStream(new BufferedOutputStream(
            new FileOutputStream(filename)));
    try {
        cf.write(out);
    }
    catch (IOException e) {
        throw e;
    }
    finally {
        out.close();
    }
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:25,代碼來源:FactoryHelper.java

示例2: transform

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
/**
 * Transform the class contained in the given file, writing the result back to the same file.
 *
 * @param file The file containing the class to be transformed
 *
 * @throws Exception Indicates a problem performing the transformation
 */
public void transform(File file) throws Exception {
	final DataInputStream in = new DataInputStream( new FileInputStream( file ) );
	final ClassFile classfile = new ClassFile( in );
	transform( classfile );

	final DataOutputStream out = new DataOutputStream( new FileOutputStream( file ) );
	try {
		classfile.write( out );
	}
	finally {
		out.close();
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:FieldTransformer.java

示例3: toBytecode

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
private static byte[] toBytecode(ClassFile cf) throws IOException {
    ByteArrayOutputStream barray = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(barray);
    try {
        cf.write(out);
    }
    finally {
        out.close();
    }

    return barray.toByteArray();
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:13,代碼來源:FactoryHelper.java

示例4: dumpClassFile

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
private void dumpClassFile(ClassFile cf) throws IOException {
    DataOutputStream dump = makeFileOutput(debugDump);
    try {
        cf.write(dump);
    }
    finally {
        dump.close();
    }
}
 
開發者ID:AndreJCL,項目名稱:JCL,代碼行數:10,代碼來源:CtClassType.java

示例5: transform

import javassist.bytecode.ClassFile; //導入方法依賴的package包/類
public void transform(File file) throws Exception {
	DataInputStream in = new DataInputStream(new FileInputStream(file));
	ClassFile classfile = new ClassFile(in);
	transform(classfile);
	DataOutputStream out = new DataOutputStream(new FileOutputStream(file));
	try {
		classfile.write(out);
	} finally {
		out.close();
	}
}
 
開發者ID:cacheonix,項目名稱:cacheonix-core,代碼行數:12,代碼來源:FieldTransformer.java


注:本文中的javassist.bytecode.ClassFile.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。