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

📄 record.java

📁 rms常用操作例子,可通过这些例子修改成你想要的代码,绝对有用!
💻 JAVA
字号:
import java.io.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
import javax.microedition.io.*;

public class Record implements DataInput {
    private RecordStore _rs;
    private byte[] _data;
    private int _length;
    private int _id;
    private DataInputStream _din;

    public Record( RecordStore rs ){
        this( rs, 100 );
    }

    public Record( 
        RecordStore rs, int initialRecordSize ){
        _rs     = rs;
        _data   = new byte[ initialRecordSize ];
        _din    = new DataInputStream(new ByteArrayInputStream( _data ) );
        _length = -1;
    }

    public byte[] getByteArray() { return _data; }

    public int getLength() { return _length; }

    public byte[] moveTo( int id ) 
                 throws RecordStoreNotOpenException,
                              InvalidRecordIDException,
                                  RecordStoreException,
                                           IOException {
        _length = _rs.getRecordSize( id );
        if( _length > _data.length ){
            _data = new byte[ _length + 40 ];
            _din  = new DataInputStream(new ByteArrayInputStream( _data ) );
        }
        _rs.getRecord( id, _data, 0 );
        _id = id;
        _din.reset();
        return _data;
    }

	public void readFully(byte b[]) throws IOException {
        _din.readFully( b );
    }

	public int skipBytes(int n) throws IOException {
	       return _din.skipBytes( n );
    }

	public void readFully(byte b[], int off, int len) throws IOException {
        _din.readFully( b, off, len );
	}

	public boolean readBoolean() throws IOException {
        return _din.readBoolean();
    }
 
    public byte readByte() throws IOException {
        return _din.readByte();
    }

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

    public short readShort() throws IOException {
        return _din.readShort();
    }

    public int readUnsignedShort() 
                                   throws IOException {
       return _din.readUnsignedShort();
    }

    public char readChar() throws IOException {
        return _din.readChar();
    }
    public int readInt() throws IOException {
        return _din.readInt();
    }

    public long readLong() throws IOException {
        return _din.readLong();
    }

    public String readUTF() throws IOException {
        return _din.readUTF();
    }
};

⌨️ 快捷键说明

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