当前位置:网站首页>Serialization and deserialization of objects
Serialization and deserialization of objects
2022-07-01 04:48:00 【Yangasang 815】
import java.io.*;
public class Test1 {
public static void main(String[] args) throws Exception {
// Object serialization
// Create objects
Student s=new Student(" Li Hua ");
ObjectOutputStream ops=
new ObjectOutputStream(new FileOutputStream(""));
// Call the serialization method directly
ops.writeObject(s);
ops.close();
// Deserialization
ObjectInputStream oin=new ObjectInputStream(new FileInputStream(""));
Student ss=(Student) oin.readObject();
oin.close();
}
}
class Student implements Serializable{
// Declare serialization version number
// The version numbers of serialization and deserialization must be consistent , If there is any change, you must serialize before deserializing
private static final long SerializableNumber=1;
// Member variables use transient modification Can't be serialized
private String name;
public Student() {
}
public Student(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
'}';
}
}边栏推荐
- 2022 tea master (intermediate) examination question bank and tea master (intermediate) examination questions and analysis
- [daily question in summer] Luogu p1568 race
- 最长递增子序列及最优解、动物总重量问题
- 【硬十宝典】——1.【基础知识】电源的分类
- CF1638E. Colorful operations Kodori tree + differential tree array
- 科研狗可能需要的一些工具
- C#读写应用程序配置文件App.exe.config,并在界面上显示
- VIM简易使用教程
- 【暑期每日一題】洛穀 P1568 賽跑
- 分布式-总结列表
猜你喜欢

【硬十宝典】——1.【基础知识】电源的分类

One click shell to automatically deploy any version of redis

pytorch 卷积操作

The longest increasing subsequence and its optimal solution, total animal weight problem

神经网络-卷积层

Pytoch (III) -- function optimization

Kodori tree board

Dataloader的使用

Extension fragment

RuntimeError: “max_pool2d“ not implemented for ‘Long‘
随机推荐
数据加载及预处理
How to use common datasets in pytorch
LeetCode_53(最大子数组和)
Leecode record 1351 negative numbers in statistical ordered matrix
LeetCode_35(搜索插入位置)
js解决浮点数相乘精度丢失问题
Basic skeleton of neural network nn Use of moudle
LeetCode_28(实现 strStr())
Pytorch neural network construction template
[FTP] the solution to "227 entering passive mode" during FTP connection
技术分享| 融合调度中的广播功能设计
Design experience of Meizhou clinical laboratory
【FTP】FTP连接时出现“227 Entering Passive Mode”的解决方法
Dataloader的使用
STM32扩展板 温度传感器和温湿度传感器的使用
RuntimeError: “max_pool2d“ not implemented for ‘Long‘
【FTP】FTP常用命令,持续更新中……
无器械健身
pytorch中常用数据集的使用方法
[summer daily question] Luogu p5886 Hello, 2020!