need some help on a files streams and object serialization i

need some help on a files streams and object serialization is to create a command-line shell application capable of executing a few basic directory- and file-based commands.

application must follow these general requirements

All classes must be in a package following these rules:

The package name is your last name plus the first letter of your first name. For example, if you name is Rita Red, her package is “red.r”

Package names are all lowercase letters

All class names must start with an UPPERCASE letter then camel-cased after that.

All property names must start with a lowercase letter then came-cased after that.

All method names must start with a lowercase letter then came-cased after that.

Output must match the examples. Watch out for spaces and punctuation.

Solution

package de.vogella.java.serilization; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; public class Main { public static void main(String[] args) { String filename = \"time.ser\"; Person p = new Person(\"Lars\", \"Vogel\"); // save the object to file FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(filename); out = new ObjectOutputStream(fos); out.writeObject(p); out.close(); } catch (Exception ex) { ex.printStackTrace(); } // read the object from file // save the object to file FileInputStream fis = null; ObjectInputStream in = null; try { fis = new FileInputStream(filename); in = new ObjectInputStream(fis); p = (Person) in.readObject(); in.close(); } catch (Exception ex) { ex.printStackTrace(); } System.out.println(p); } }
need some help on a files streams and object serialization is to create a command-line shell application capable of executing a few basic directory- and file-ba

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site