Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a Java program to track how many times the program has been executed. You will store the number (integer) representing the count into

1. Write a Java program to track how many times the program has been executed. You will store the number (integer) representing the count into a file (count.dat). If the count.dat doesnt exist (e.g., first time to run the program), store 1 in the newly created file. You will use binary IO (FileInputStream / FileOutputSteam) for your code. For this question, you will also need to declare the checked exceptions in the methods header to handle errors. Since the counter.dat file is a binary file (you cannot read it with your typical text editor(eg MS words), you can use your Hex viewer method program from the following question to open the file to examine the contents. If you are using notepad++, you can also download the HexEditor plugin to enable the Hex view. Please submit your count.dat file as well as the java file for this question

2. Write a Hex Viewer method with the following header to read a binary file.

private static void viewHex(String filename)

This method reads bytes from the file (data.dat, and your counter.dat from the previous question) and displays them in hex representation. The output should be formatted as shown in the example below. Each line consists of 8 pairs of hex numbers, then |, then another 8 pairs. Use Integer.toHexString( ) to convert a byte into a string representing the equivalent hex. Use try statement to handle IOException and display a simple error message if an I/O exception occurs.

3. Write a program to display the student information (First name, Study Major, and ID #) that you have just entered. For this problem, you need to create an ArrayList with xyz as the StudentEntry type parameter. You will need to create a method ( getEntry ( ) ) to read in the three student information and return the StudentEntry type for the ArrayList . Within the package, create a separate file for the Student entry class. For exception handling, you need to provide a try-catch block and allow user to re-enter if the input format is not correct. For displaying the results, you will use both the for-each and Iterator method as shown in the following example

image text in transcribedimage text in transcribed

image text in transcribed

This assignment deals with writing programs in the areas of Binary file IO, and handling Arraylist with generic parameters. The assignment also exercises some of the try-catch block exception handling methods from the previous lectures. (15 marks) Write a Java program to track how many times the program has been executed. You will store the number (integer)representing the count into a file (count.dat). If the count.dat doesn't exist (e.g., first time to run the program), store 1 in the newly created file. You will use binary IO FilelnputStream/ FileOutputSteam) for your code. For this question, you will also need to declare the checked exceptions in the method's header to handle errors. Since the counter.dat file is a binary file (you cannot read it with your typical text editor(eg MS words), you can use your Hex viewer method program from the following question to open the file to examine the contents. If you are using notepad++, you can also download the HexEditor plugin to enable the Hex view. Please submit your count.dat file as well as the java file for this question 1. 2. (10 Pts) Write a Hex Viewer method with the following header to read a binary file. private static void viewHex (String filename) This method reads bytes from the file (data.dat, and your counter.dat from the previous question) and displays them in hex representation. The output should be formatted as shown in the example below. Each line consists of 8 pairs of hex numbers, then 'I', then another 8 pairs. Use Integer.toHexString) to convert a byte into a string representing the equivalent hex. Use try statement to handle lOExceptionand display a simple error message if an I/O exception occurs. This assignment deals with writing programs in the areas of Binary file IO, and handling Arraylist with generic parameters. The assignment also exercises some of the try-catch block exception handling methods from the previous lectures. (15 marks) Write a Java program to track how many times the program has been executed. You will store the number (integer)representing the count into a file (count.dat). If the count.dat doesn't exist (e.g., first time to run the program), store 1 in the newly created file. You will use binary IO FilelnputStream/ FileOutputSteam) for your code. For this question, you will also need to declare the checked exceptions in the method's header to handle errors. Since the counter.dat file is a binary file (you cannot read it with your typical text editor(eg MS words), you can use your Hex viewer method program from the following question to open the file to examine the contents. If you are using notepad++, you can also download the HexEditor plugin to enable the Hex view. Please submit your count.dat file as well as the java file for this question 1. 2. (10 Pts) Write a Hex Viewer method with the following header to read a binary file. private static void viewHex (String filename) This method reads bytes from the file (data.dat, and your counter.dat from the previous question) and displays them in hex representation. The output should be formatted as shown in the example below. Each line consists of 8 pairs of hex numbers, then 'I', then another 8 pairs. Use Integer.toHexString) to convert a byte into a string representing the equivalent hex. Use try statement to handle lOExceptionand display a simple error message if an I/O exception occurs

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Explain what a subroutine is.

Answered: 1 week ago