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

📄 businessinhelper.java

📁 局域网聊天系统
💻 JAVA
字号:
package com.soft.QQ;
import java.io.*;
import java.nio.ByteBuffer;
import static com.soft.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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -