📄 gamerms.java
字号:
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
public class GameRMS
{
//排行榜数据编码,解码器
String name;
long score;
public GameRMS(String n,long s)
{
name = n;
score = s;
}
public GameRMS()
{
}
//将数据编码
public byte[] encode()
{
byte[] result = null;
try
{
ByteArrayOutputStream bos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(bos);
dos.writeUTF(name);
dos.writeLong(score);
result = bos.toByteArray();
dos.close();
bos.close();
}catch(Exception s){}
return result;
}
//将数据解码
public void decode(byte[] data)
{
try
{
ByteArrayInputStream bis = new ByteArrayInputStream(data);
DataInputStream dis = new DataInputStream(bis);
name = dis.readUTF();
score = dis.readLong();
dis.close();
bis.close();
}catch(Exception e){}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -