Please could you please amend the java code below to serialize and deserilize an object using FileOutputStrean and FileInputStream.
Please could I have a typewritten answer.
//Java Code to Serialize and Deserialize the objects
import java.io.*;
import java.io.Serializable;
class Dog implements Serializable {
String breed;
int age;
String colour;
//Constructor of class Dog
public Dog(String breed, int age, String colour) {
this.breed = breed;
this.age = age;
this.colour=colour;
}
}
public class SerDeser{
public static void main(String args[])throws Exception{
//Creating object using constructor
Dog d =new Dog("BullDog", 2,"Brown");
FileOutputStream fout=new FileOutputStream("file1.txt");
ObjectOutputStream out=new ObjectOutputStream(fout); //converting
objects into a stream
out.writeObject(d); //Writing object to a file
out.flush();
ObjectInputStream in=new ObjectInputStream(new
FileInputStream("file1.txt")); //Reading Streams into objects
Dog d1=(Dog)in.readObject(); //Reading object from a file
System.out.println(d1.breed+" "+d1.age+" "+d1.colour); //Printing
the object
in.close();
}
}
$javac SerDeser.java
$java SerDeser
BullDog 2 Brown
Please could you please amend the java code below to serialize and deserilize an object using...
Java: In the code example below, explain the purpose of the catch block. (The last 4 lines of code.) FileInputStream inFileStream; Scanner scanner; scanner = new Scanner( System.in ); System.out.print("Enter filename to open: "); String filename = scanner.next(); try { InFileStream = new FileInputStream( filename ); } catch (Exception e) { inFileStream = new FileInputStream("default.dat"); }
write the following code in java thank you and if you can, could you please write the code in replit and sent me a link to it replit is basically like a online compiler and you can write java code on it thank you The first part is to implement one of the questions from your examination. /* A Range objects represents an integer range, such as 1-10 or 50701-50799. The lower and upper bounds of a Range are given...
in BASIC/BEGINNER OBJECT ORIENTATED JAVA Please write code for the following program using comments explaining the code. (You can hand write this). Give a UML example illustrating AGGREGATION. Include classes, fields, methods, instance fields. USE ONE SUPER CLASS AND TWO SUB CLASSES. Include pcode for at least one method of each class. Explain the whole part relationship and if this a deep or shallow copy.
Exercise 1: Understanding Object Oriented Design Principles [Please Answer clearly using python, No java code only python] What are the differences between an abstract class and an interface class? Present 02 examples one of an abstract class and one of an interface class in python
A College wants to build their Student Information Systems (SIS). Whenever a new Student is added to the college, the details need to be recorded in a text file. Student information officer should be able to use the SIS to retrieve information from the text file and display it on the screen. The system also needs to be able to format or parse strings retrieved from the text file. I am using Eclipse IDE to write java code. Can I...
In the following graph, write a Java program using Topological Sort. please write java code and show me the output. Thank you :) b.
Java code to read from .csv file i currently have a .csv file that looks like this: 39.743222, -105.006241, Hospital 39.743981, -105.020017, Home 39.739377, -104.984774, Firehouse 39.627779, -104.839291, McDonald's 39.731919, -104.961814, Chipotle I need to write code to extract the doubles from each line to use for my Linked List. this is what i have so far: Scanner in = new Scanner(new FileInputStream(DATA_FILE));
Java I just need the answer to the questions, not the whole implemented code please You have an object of the RandomAccessFile class named empRaf. It refers to a physical file that contains a company's employee records. Each employee record has: an int field named empID which points to its location in the file a 20 character last name a 15 character first_name a hire date stored as an int a 3 character job code The empID values begin at...
write in java and please code the four classes with the requirements instructed You will be writing a multiclass user management system using the java. Create a program that implements a minimum of four classes. The classes must include: 1. Employee Class with the attributes of Employee ID, First Name, Middle Initial, Last Name, Date of Employment. 2. Employee Type Class that has two instances of EmployeeType objects: salaried and hourly. Each object will have methods that calculates employees payrol...
Java programming. Please, could you add the comment so I can follow and understand. Thanks Create a program with JavaFX that displays a bouncing graphics (an image of a ball or the head of Darth Vader or anything else). The object should bounce around in the window. There should also be a button in the win- dow that releases another object (unlimited number should be possible to have in the window, but only one new object should be released for...