Simple java program Topic Binary File IO Create a simple app

Simple java program:

Topic: Binary File I/O

Create a simple application called contact list that will accept a person’s first and last name from a dialog box, the accept a phone number from a dialog box.

Now save that information to a binary file.

You’ll only have one record.
----------------------------

Next,

Go back to your contact list application modify it such that that will accept a person’s first and last name from a dialog box, then accept a phone number from a dialog box. It will repeat this process until the user types in some sentinel value (terminating value) for name.

If the file doesn’t exist currently, you’ll create a new file. If it does, you’ll append to it.

Solution

public class SimpleJava {

     string first,last, phone;

     public static void main(String[] args) throws Exception {

           String first = System.console().readLine();

           DataOutputStream out = openOutputStream(\"binary\");

           while(!first.equals(\"Terminate\")) {

      String last = System.console().readLine();

      String phone = System.console().readLine();

              out.writeUTF(first+last+phone);

              String first = System.console.readline();

          }

   }

  

}

Simple java program: Topic: Binary File I/O Create a simple application called contact list that will accept a person’s first and last name from a dialog box, t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site