businessinhelper.java~3~

来自「局域网聊天系统」· JAVA~3~ 代码 · 共 49 行

JAVA~3~
49
字号
package com.soft.QQ;
import java.io.*;
import java.nio.ByteBuffer;
import static com.sun.QQ.Config.*;
import java.nio.ByteOrder;

public class BusinessInHelper {
    private ByteBuffer bb;
    private int len;



    public BusinessInHelper(byte[] buf) {
        if (buf != null) {
            this.len = buf.length - END_SYMBOL.length();
            bb = ByteBuffer.wrap(buf, 0, len);
            bb.order(ByteOrder.LITTLE_ENDIAN);
        }
    }

    public int getInt() {
        return bb.getInt();
    }

    public long getLong(){
        return bb.getLong();
    }

    public String getString(int length) throws IOException {
        byte[] buf = new byte[length];
        for (int i = 0; i < length; i++) {
            buf[i] = bb.get();
        }
        return new String(buf, "GBK").trim();
    }

    public String getString(int length, String encode) throws IOException {
        byte[] buf = new byte[length];
        for (int i = 0; i < length; i++) {
            buf[i] = bb.get();
        }
        return new String(buf, encode).trim();
    }

    public byte getByte() {
        return bb.get();
    }
}

⌨️ 快捷键说明

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