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

📄 dbrecord.java

📁 J2ME 无线通信技术应用开发源代码
💻 JAVA
字号:
//程序名DbRecord.java,项目RMS_Ex8
import java.io.*;

class DbRecord {
	static char[] name = new char[8];
	static int serial;
	static int Chinese,Maths;
	static boolean isPass;
	static byte[] recordByte = new byte[15];

  public static void set(char[] name, int serial, int Chinese, int Maths, boolean isPass) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream (baos);
		OutputStreamWriter osw = new OutputStreamWriter(dos);
		try {
			osw.write(name,0,name.length);
			osw.flush();
			dos.writeInt(serial);
			dos.write(Chinese);
			dos.write(Maths);
			dos.writeBoolean(isPass);
			dos.flush();
			baos.flush();
			recordByte = baos.toByteArray();
			osw.close();
			dos.close();
			baos.close();
		} catch (IOException e) {
			//处理异常
		}
  }
  
  public static void get(byte[] b) {
		DataInputStream dis = 
			new DataInputStream(
				new ByteArrayInputStream(b));
		InputStreamReader isr = new InputStreamReader(dis);
		try {
			isr.read(name,0,8);
			serial = dis.readInt();
			Chinese = dis.readUnsignedByte();
			Maths = dis.readUnsignedByte();
			isPass = dis.readBoolean();
			isr.close();
			dis.close();
		} catch (IOException e) {
			//处理异常
		}
  }
  
  public static void print() {
   	System.out.print(DbRecord.name);
   	System.out.print("\t"+DbRecord.serial);
   	System.out.print("\t"+DbRecord.Chinese);
   	System.out.print("\t"+DbRecord.Maths);
   	System.out.println("\t"+DbRecord.isPass);
  }

  public static void title() {
   	System.out.println("name\tserial\tChinese\tMaths\tPass");
  }
}

⌨️ 快捷键说明

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