bytesutile.java

来自「封装了SQL、Socket、WAP、MIME等功能的通用组件」· Java 代码 · 共 51 行

JAVA
51
字号
package org.lazybug.util;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: lazybug</p>
 *
 * @author David Lau
 * @version 1.0
 */
public class BytesUtile
{
    private static final int SIZE = 500*1024;
    private static byte[] buffer = new byte[SIZE];
    private static int index = 0;

    public static void init()
    {
        index = 0;
    }

    public static void write(int ch)
    {
        buffer[index++] = (byte)ch;
    }

    public static void rollback(int k)
    {
        index -= k;
        if( index < 0 ) index = 0;
    }

    public static byte[] getPayload()
    {
//        System.out.println("getPayload:"+index);
        byte buf[] = new byte[index];
        index = 0;
        Tools.copyByteArray(buffer, buf);
        return buf;
    }

    public static void main( String[] args )
    {
        BytesUtile bytesutile = new BytesUtile();
    }
}

⌨️ 快捷键说明

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