当前位置: 首页>>代码示例>>Java>>正文


Java Constants.MiB方法代码示例

本文整理汇总了Java中cuchaz.enigma.Constants.MiB方法的典型用法代码示例。如果您正苦于以下问题:Java Constants.MiB方法的具体用法?Java Constants.MiB怎么用?Java Constants.MiB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cuchaz.enigma.Constants的用法示例。


在下文中一共展示了Constants.MiB方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getClass

import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry) throws IOException, NotFoundException {
	// read the class into a buffer
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	byte[] buf = new byte[Constants.KiB];
	int totalNumBytesRead = 0;
	InputStream in = jar.getInputStream(entry);
	while (in.available() > 0) {
		int numBytesRead = in.read(buf);
		if (numBytesRead < 0) {
			break;
		}
		bos.write(buf, 0, numBytesRead);
		
		// sanity checking
		totalNumBytesRead += numBytesRead;
		if (totalNumBytesRead > Constants.MiB) {
			throw new Error("Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!");
		}
	}
	
	// get a javassist handle for the class
	String className = Descriptor.toJavaName(getClassEntry(entry).getName());
	ClassPool classPool = new ClassPool();
	classPool.appendSystemPath();
	classPool.insertClassPath(new ByteArrayClassPath(className, bos.toByteArray()));
	return classPool.get(className);
}
 
开发者ID:cccssw,项目名称:enigma-vk,代码行数:28,代码来源:JarClassIterator.java

示例2: getClass

import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry) throws IOException, NotFoundException {
    // read the class into a buffer
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    byte[] buf = new byte[Constants.KiB];
    int totalNumBytesRead = 0;
    InputStream in = jar.getInputStream(entry);
    while (in.available() > 0) {
        int numBytesRead = in.read(buf);
        if (numBytesRead < 0) {
            break;
        }
        bos.write(buf, 0, numBytesRead);

        // sanity checking
        totalNumBytesRead += numBytesRead;
        if (totalNumBytesRead > Constants.MiB) {
            throw new Error("Class file " + entry.getName() + " larger than 1 MiB! Something is wrong!");
        }
    }

    // get a javassist handle for the class
    String className = Descriptor.toJavaName(getClassEntry(entry).getName());
    ClassPool classPool = new ClassPool();
    classPool.appendSystemPath();
    classPool.insertClassPath(new ByteArrayClassPath(className, bos.toByteArray()));
    return classPool.get(className);
}
 
开发者ID:OpenModLoader,项目名称:Enigma,代码行数:28,代码来源:JarClassIterator.java

示例3: getClass

import cuchaz.enigma.Constants; //导入方法依赖的package包/类
private static CtClass getClass(JarFile jar, JarEntry entry)
	throws IOException, NotFoundException
{
	// read the class into a buffer
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	byte[] buf = new byte[Constants.KiB];
	int totalNumBytesRead = 0;
	InputStream in = jar.getInputStream(entry);
	while(in.available() > 0)
	{
		int numBytesRead = in.read(buf);
		if(numBytesRead < 0)
			break;
		bos.write(buf, 0, numBytesRead);
		
		// sanity checking
		totalNumBytesRead += numBytesRead;
		if(totalNumBytesRead > Constants.MiB)
			throw new Error("Class file " + entry.getName()
				+ " larger than 1 MiB! Something is wrong!");
	}
	
	// get a javassist handle for the class
	String className =
		Descriptor.toJavaName(getClassEntry(entry).getName());
	ClassPool classPool = new ClassPool();
	classPool.appendSystemPath();
	classPool.insertClassPath(new ByteArrayClassPath(className, bos
		.toByteArray()));
	return classPool.get(className);
}
 
开发者ID:Wurst-Imperium,项目名称:Wurst-Enigma,代码行数:32,代码来源:JarClassIterator.java


注:本文中的cuchaz.enigma.Constants.MiB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。