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

📄 peekinputstream.java

📁 用Java写的彩信的程序。包括wsp/mime/mms几部分。
💻 JAVA
字号:
/* 
 * JVending - J2ME MMS Client
 *
 * Distributed under Apache style software license included with the source code.
 */

package org.jvending.messaging.io;

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.IOException;

import org.jvending.messaging.util.SimpleQueue;

/**
 * @author Shane Isbell
 * @version 1.0.0a
 * @created 04/03/28
 */

public class PeekInputStream {
    
    private InputStream dis;

    private int[] peekStack;

    private int internalCounter;

    private int lookahead;

    private int bufferSize;

    private SimpleQueue peekQueue;

    public PeekInputStream(InputStream is) {
          this.dis = is;
        bufferSize = 5;
        peekQueue = new SimpleQueue(bufferSize);
    }

    public PeekInputStream(InputStream is, int bufferSize) {
          this.dis = is;
        this.bufferSize = bufferSize;
        peekQueue = new SimpleQueue(bufferSize);
    }

    public int readUnsignedByte() throws IOException {
        return this.readByte();
    }

    public int read(byte[] b, int off, int len) throws IOException {
        return dis.read(b, off, len);
    }

    public int readByte() throws IOException {//was readByte()
        if(peekQueue.isEmpty()) {
            return dis.read();
        } else {
            return ((Integer) peekQueue.dequeue()).intValue();
        }
    }

    public void clearQueue() {
        peekQueue = new SimpleQueue(bufferSize);
    }

    public int peekUnsignedByte(int look) throws IOException, IndexOutOfBoundsException {
        return (peekByte(look) & 0x7f);
    }

    //needs more work
    public int peekByte(int look) throws IOException, IndexOutOfBoundsException {
          int b = 0;
        for(int i = 0; i < look; i++) {
            b = dis.read();
            if(b != -1) peekQueue.enqueue(new Integer(b));
        }       
        return b;
    }
}

⌨️ 快捷键说明

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