Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Reading and Writing Files of different Formats Using JAVA Consider the following Account Class _______________________________________________________________________ public class Account { private String name; private BigDecimal amount;

Reading and Writing Files of different Formats Using JAVA

Consider the following Account Class

_______________________________________________________________________

public class Account {

private String name;

private BigDecimal amount;

public Account(String acctName, String startAmount) {

this.setName(acctName);

this.setAmount(startAmount);

}

public String getName() {

return this.name;

}

public BigDecimal getAmount() {

return this.amount;

}

public void setName(String newName) {

String pattern = "^[a-zA-Z0-9]*$";

if (newName.matches(pattern)) {

this.name = newName;

}

}

private void setAmount(String newAmount){

this.amount = new BigDecimal(newAmount);

}

}

_______________________________________________________________________

Serialization

  1. Write a class SerializationHandler that supports a serialize() method, which takes as parameters an instance of the account class and serializes it to a file account.ser. The class also must support a deserialize() method which reads and returns the data of an account object. Write the client code to test the SerializationHandler class.

XML Files

  1. Write another class called XMLHandler that supports a Write() method that takes a name value pair, as strings, and writes them to an XML file. The class must also support a read() method that takes a name and retrieves its value from the XML file. Use this class to store the name value pair: name=JSONPath value=[path to a JSON file that will be used below in the JSON Files section]

JSON Files

  1. Write another class called JSONHandler that supports a write() method which takes an Account object and writes it to a file in a JSON format. The class also supports a read() method which reads data from a JSON file into an object. Write the client code to test the process. The JSON file path should be stored in and read from the XML file.

Properties

  1. Write another class called PropertiesHandler that supports a write() method, which takes a name value pair as strings and stores these in a properties file config.properties. The class must also support a read() method that takes a name and retrieves its value from the config.properties file. Use the Java class library java.util.Properties. Write the client code to test the PropertiesHandler class.

Preferences

  1. Write another class called PreferencesHandler that supports a write() method, which takes a name value pair as strings and stores these as a user preferences on the machine. The class must also support a read() method that takes a name and retrieves its value from the preferences store. Use the Java class library java.util.prefs.Preferences. Write the client code to test the PreferencesHandler class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago