Confused about File Input and Output Assignment

This is my last Java programming assignment before my final exam. Unfortunately, neither my textbook not the online module is really helping me figure this assignment out!

The purpose of this assignment is to create a sequential file and then use that file by printing its contents. This assignment requires an application (not an applet) since I am using files.

Assignment Requirements:

1. Create one source file named PhoneList.java. This application will create a file of names and phone numbers.

2. Prompt the user to enter the file name using a dialog box. Dialog box says: "Please enter the file name. \nInclude drive and folder (C:\Temp\file_name)." There are no edits required for this data.

3. Prompt the user to enter the name of your friend using a dialog box. Dialog box says: "Please enter friend's name:". There are no edits required for this data.

4. Prompt the user to enter the telephone number using a dialog box. Dialog box says" "Please enter friend's telephone number (nnn-nnn-nnnn):" There are no edits required for this data.

5. Write the name and telephone number to a file.

6. Prompt the user to determine if he/she has more data to enter. Repeat the above process if the answer is yes. Read the file and print all the information on the console screen if the answer is no and then end the application. Your printed output on the console will look like this: "The Employee name is: John Doe phone extension is : 212-555-1234"

7. All statements that read/write files, must be in try blocks. Each try block block must have at least one catch block. You may have more. You must use at least one finally block. All statements that instantiate I/O objects must be in try blocks. Each try block block must have at least one catch block. You may have more. You may use System.exit(1) to end your application if any of the object instantiations fail or if you have an I/O error.

8. Do not use any class wide variables. That is, all the variables you create in this assignment must be declared within a method.

I've tried to write this as best as I can by using examples in my textbook and previous assignments, but I'm certain that there are quite a few logic errors in my code. I just don't know enough to identify and fix them.

When I run the application, the first three dialog boxes execute, the application terminates and I get nothing in my console. :confused:

Does anyone have any recommendations on how to fix my code to make this work? Thank you!

try
{
writeToFile(outputPhoneListFile, friendName, phoneNumber);
}
catch (IOException e)
{
System.out.println("Unable to create " + fileName +": " + e.getMessage());
}
finally
{
outputPhoneListFile.close();
System.exit(1);
}
no matter it throws the IOException, the finally block will be executed all the time. so , you application is exit. you can not get any output in your console.