📄 index.java
字号:
/*
* Index.java
*
* Created on 2006年3月19日, 上午11:14
*
* To change this template, choose Tools | Options and locate the template under
* the Source Creation and Management node. Right-click the template and choose
* Open. You can then make changes to the template in the Source Editor.
*/
package com.j2medev.sample.phonebook;
import java.io.*;
/**
*
* @author Admin
*/
public class Index {
private String key;
private int recordID;
/** Creates a new instance of Index */
public Index() {
}
public Index(String key,int recordID){
this.key = key;
this.recordID = recordID;
}
public void setKey(String key){
this.key = key;
}
public void setRecorID(int recordID){
this.recordID = recordID;
}
public String getKey(){
return key;
}
public int getRecordID(){
return recordID;
}
public byte[] serialize() throws IOException{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
dos.writeUTF(key);
dos.writeInt(recordID);
baos.close();
dos.close();
return baos.toByteArray();
}
public static Index deserialize(byte[] data) throws IOException{
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
Index index = new Index();
index.key = dis.readUTF();
index.recordID = dis.readInt();
dis.close();
bais.close();
return index;
}
public static boolean matches(byte[] data,String key,int flag) throws IOException{
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
if(flag == 0){
return (dis.readUTF()).equals(key);
}else if((dis.readUTF()).indexOf(key) == -1){
return false;
}else{
return true;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -