?? index.java
字號:
/*
* Created on 2004-7-11
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package com.north.phonebook.model;
import java.io.*;
/**
* @author P2800
*
* TODO To change the template for this generated type comment go to Window -
* Preferences - Java - Code Style - Code Templates
*/
public class Index
{
private String key;
private int recordID;
public Index(String key, int recordID)
{
this.key = key;
this.recordID = recordID;
}
private Index()
{
}
/**
* @return Returns the key.
*/
public String getKey()
{
return key;
}
/**
* @param key The key to set.
*/
public void setKey(String key)
{
this.key = key;
}
/**
* @return Returns the recordID.
*/
public int getRecordID()
{
return recordID;
}
/**
* @param recordID The recordID to set.
*/
public void setRecordID(int recordID)
{
this.recordID = 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();
bais.close();
dis.close();
return index;
}
public static boolean matches(byte[] data, String key,int type) throws IOException
{
ByteArrayInputStream bais = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bais);
if(type == 101)
{
return (dis.readUTF()).equals(key);
}
else if(type == 102)
{
return (dis.readUTF()).startsWith(key);
}
return false;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -