- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is Serialization in Java?
Java provides a mechanism, called object serialization where an object can be represented as a sequence of bytes that includes the object's data as well as information about the object's type and the types of data stored in the object.
Example
import java.io.*; public class SerializeDemo { public static void main(String [] args) { Employee e = new Employee(); e.name = "Reyan Ali"; e.address = "Phokka Kuan, Ambehta Peer"; e.SSN = 11122333; e.number = 101; try { FileOutputStream fileOut = new FileOutputStream("/tmp/employee.ser"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(e); out.close(); fileOut.close(); System.out.printf("Serialized data is saved in /tmp/employee.ser"); } catch (IOException i) { i.printStackTrace(); } } }
- Related Articles
- What is the difference between Serialization and Deserialization in Java?
- What is serialization in C#.NET?
- Object Graph in Java Serialization
- Object Serialization with inheritance in Java
- What is Binary Serialization and Deserialization in C# and how to achieve Binary Serialization in C#?
- Difference between Serialization and Externalization in Java
- Object Serialization with Inheritance in Java Programming
- How transient works with final in Java serialization?
- How to implement custom JSON serialization with Gson in Java?
- How to exclude a field in Gson during serialization in Java?
- How to implement custom JSON de-serialization with Gson in Java?
- How can we ignore the fields during JSON serialization in Java?
- How to control serialization through @JSON annotation using flexjson in Java?
- How to ignore a class during the serialization using Jackson in Java?
- C# object serialization

Advertisements