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

📄 noterecord.java

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


public class NoteRecord {											//标注类
	private int id = 0;											//RS中ID号
	private String note = null;									//标注内容
	private int line = 0;											//书中位置
	
	//无参构造方法
	NoteRecord(){}
	
	//访问方法
	public String getNote(){
		return this.note;
	}
	public int getID(){
		return id;
	}
	public int getLine(){
		return line;
	}
	
	//加工方法
	public void setNote(String note){
		this.note = note;
	}
	public void setLine(int line){
		this.line = line;
	}
	public void setID(int id){
		this.id = id;
	}
	
	//序列化与反序列化
	public byte[] serialization(){
		byte[] data = null;
		try{
			ByteArrayOutputStream baos = new ByteArrayOutputStream();
			DataOutputStream dos = new DataOutputStream(baos);
			dos.writeInt(id);
			dos.writeUTF(note);
			dos.writeInt(line);
			dos.close();
			baos.close();
			data = baos.toByteArray();
		}catch (Exception e){
			e.printStackTrace();
		}
		return data;
	}
	static public NoteRecord deserialization(byte[] data){
		NoteRecord nr = null;
		try{
			int id;
			String note;
			int line;
			ByteArrayInputStream bais = new ByteArrayInputStream(data);
			DataInputStream dis = new DataInputStream(bais);
			id = dis.readInt();
			note = dis.readUTF();
			line = dis.readInt();
			dis.close();
			bais.close();
			nr = new NoteRecord();
			nr.setID(id);
			nr.setNote(note);
			nr.setLine(line);
		}catch (Exception e){
			e.printStackTrace();
		}
		return nr;
	}
}

⌨️ 快捷键说明

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