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

📄 winner.java

📁 j2me的一款钓鱼的游戏
💻 JAVA
字号:
package Kidfishing;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class Winner {
	String name;
	int count;

	public Winner(String name, int count) {
		this.name = name;
		this.count = count;
	}

	public Winner(byte[] temp) {
		getData(temp);
	}

	public byte[] getByte() {
		byte temp[] = null;

		ByteArrayOutputStream abos = new ByteArrayOutputStream();
		DataOutputStream dos = new DataOutputStream(abos);

		try {
			dos.writeUTF(name);
			dos.writeInt(count);

			temp = abos.toByteArray();

			abos.close();
			dos.close();
		} catch (IOException e) {

			e.printStackTrace();
		}

		return temp;
	}

	public void getData(byte[] temp) {
		ByteArrayInputStream abis = new ByteArrayInputStream(temp);

		DataInputStream dis = new DataInputStream(abis);

		try {
			name = dis.readUTF();
			count = dis.readInt();
			abis.close();
			dis.close();
		} catch (IOException e) {

			e.printStackTrace();
		}
	}
}

⌨️ 快捷键说明

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