constantutf8info.java

来自「本人根据自己的实际情况」· Java 代码 · 共 45 行

JAVA
45
字号
/**
 *
 */
package gen.info.constant;

import gen.ClassFile;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * @author liuyi
 *
 */
public class ConstantUtf8Info extends CpInfo {
    
    /** string with Utf8 encoding */
    private byte[] bytes;
    
    /**
     * @param tag
     */
    public ConstantUtf8Info(byte[] bytes, ClassFile classFile) {
        super(CONSTANT_Utf8, classFile);
        
        this.bytes = bytes;
    }
    
    public byte[] getBytes(){
        return bytes;
    }
    
    public String getRefString(){
        return new String(bytes);
    }
    
    public String toString(){
        return "const #" + index + " = Asciz\t" + getRefString();
    }
    
    public void toBinary(DataOutputStream writer) throws IOException{
        writer.writeByte(tag);
        writer.writeShort(bytes.length);
        writer.write(bytes);
    }    
}

⌨️ 快捷键说明

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