java 對(duì)象輸入輸出流讀寫文件的操作實(shí)例
創(chuàng)新互聯(lián)專注于頭屯河網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供頭屯河營(yíng)銷型網(wǎng)站建設(shè),頭屯河網(wǎng)站制作、頭屯河網(wǎng)頁(yè)設(shè)計(jì)、頭屯河網(wǎng)站官網(wǎng)定制、小程序定制開發(fā)服務(wù),打造頭屯河網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供頭屯河網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。java 支持對(duì)對(duì)象的讀寫操作,所操作的對(duì)象必須實(shí)現(xiàn)Serializable接口。
實(shí)例代碼:
package vo; import java.io.Serializable; public class Animal implements Serializable { private static final long serialVersionUID = 1L; private String name; private Integer weight; private String color; private String type; private Integer age; private Integer lifetime; public String getName() { return name; } public void setName(String name) { this.name = name; } public Integer getWeight() { return weight; } public void setWeight(Integer weight) { this.weight = weight; } public String getColor() { return color; } public void setColor(String color) { this.color = color; } public String getType() { return type; } public void setType(String type) { this.type = type; } public Integer getAge() { return age; } public void setAge(Integer age) { this.age = age; } public Integer getLifetime() { return lifetime; } public void setLifetime(Integer lifetime) { this.lifetime = lifetime; } public Animal(String name, Integer weight, String color, String type, Integer age, Integer lifetime) { super(); this.name = name; this.weight = weight; this.color = color; this.type = type; this.age = age; this.lifetime = lifetime; } @Override public String toString() { return "Animal [name=" + name + ", weight=" + weight + ", color=" + color + ", type=" + type + ", age=" + age + ", lifetime=" + lifetime + "]"; } }