2 Star 0 Fork 0

20155207wxc/besti-java-20155207wxc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Member.java 1.44 KB
一键复制 编辑 原始数据 按行查看 历史
lnaswxc 提交于 2017-06-01 14:37 . 实验五
package cc.openhome;
import java.io.*;
public class Member {
private String number;
private String name;
private int age;
public Member(String number, String name, int age) {
this.number = number;
this.name = name;
this.age = age;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public String toString() {
return String.format("(%s, %s, %d)", number, name, age);
}
public void save() throws IOException {
try(DataOutputStream output =
new DataOutputStream(new FileOutputStream(number))) {
output.writeUTF(number);
output.writeUTF(name);
output.writeInt(age);
}
}
public static Member load(String number) throws IOException {
Member member;
try(DataInputStream input =
new DataInputStream(new FileInputStream(number))) {
member = new Member(
input.readUTF(), input.readUTF(), input.readInt());
}
return member;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/lnaswxc/besti-java-20155207wxc.git
git@gitee.com:lnaswxc/besti-java-20155207wxc.git
lnaswxc
besti-java-20155207wxc
besti-java-20155207wxc
master

搜索帮助