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

📄 bookmark.java

📁 本程序用JavaME语言描述了一个运行在手机上的电子书系统
💻 JAVA
字号:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;

public class BookMark {									//书签类
	private String cento = null;							//页面首句摘录或自定义内容
	private int line = 0;									//文本中的位置
	private int id = 0;									//RS中的ID号
	
	//构造方法
	public BookMark(){
	}
	public BookMark(String cento, int line, int id){
		this.cento = cento;
		this.line = line;
		this.id = id;
	}

	//访问方法
	public String getCento(){
		return cento;
	}
	public int getLine(){
		return line;
	}
	public int getID(){
		return id;
	}
	//加工方法
	public void setCento(String cento){
		this.cento = cento;
	}
	public void setID(int id){
		this.id = id;
	}
	public void setLine(int line){
		this.line = line;
	}
	
	//序列化
	public byte[] serialization(){
		byte[] data = null;
		try{
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream dos = new DataOutputStream(baos);
			dos.writeUTF(cento);
			dos.writeInt(line);
			dos.writeInt(id);
			dos.close();
			baos.close();
			data = baos.toByteArray();
		}catch (Exception e){
			e.printStackTrace();
		}
		return data;
	}
	
	//反序列化
	static public BookMark deserialization(byte[] data){
		String cento = null;
		int line = 0;
		int id = 0;
		try{
			ByteArrayInputStream bais = new ByteArrayInputStream(data);
			DataInputStream dis = new DataInputStream(bais);
			cento = dis.readUTF();
			line = dis.readInt();
			id = dis.readInt();
			dis.close();
			bais.close();
		}catch (Exception e){
			e.printStackTrace();
		}
		BookMark bk = new BookMark(cento, line, id);
		return bk;
	}
}

⌨️ 快捷键说明

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