Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cw5;
- import java.io.Serializable;
- public class Book implements Serializable {
- private static final long serialVersionUID = 1L;
- private String bookName;
- private String author;
- public Book(String bookName, String author) {
- this.bookName = bookName;
- this.author = author;
- }
- public String getBookName() {
- return bookName;
- }
- public void setBookName(String bookName) {
- this.bookName = bookName;
- }
- public String getAuthor() {
- return author;
- }
- public void setAuthor(String author) {
- this.author = author;
- }
- public String toString() {
- return ("Book name: " + bookName + "\nAuthor name: " + author );
- }
- }
- =====================================================
- package cw5;
- import java.io.FileInputStream;
- import java.io.IOException;
- import java.io.ObjectInputStream;
- public class BinaryInputFile {
- public static void main(String[] args) throws IOException {
- FileInputStream file = new FileInputStream("test.bin");
- ObjectInputStream in = new ObjectInputStream(file);
- for(int i = 0; i < 10; i++)
- System.out.println(in.readInt());
- in.close();
- System.out.println("Done");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement