Question: JAVA Program that will read from a text file and split/store into different arrays. This program will use line-based file processing to access each line

JAVA Program that will read from a text file and split/store into different arrays.

This program will use line-based file processing to access each line in the file, but will need to use token-based processing to figure out which type of information is being provided.

you will read from a text file that contains (for example) :

Name: Thomas M Anders Phone: 206-365-1844 Email: tommanders*email.com Address: 2884 University Street Seattle, Washington 98155

NAME: Deanna Simmons EMAIL: noah.sanfor**email.com PHONE: 360-480-6692 ADDRESS: 1169 Boone Crockett Lane Olympia, Washington 98501

Name: Willie A Johnson Address: 2796 Camden Place Elmsford, New York 10523 Phone: 845-222-2739 Email: will1982*email.com

Name: Missy McCarthy Phone: 270-764-8310 Address: 3540 Coffman Alley Stanley, Kentucky 42375 Email: missmccarthy*email.com

Name: Robert B Ramirez Email: Bob1973*email.com Phone: 832-462-2414 Address: 3101 Circle Drive Houston, Texas 77063

Storing the Data

You should read the file in from contacts.txt (contains the example above of what that text file contains) and store the information in multiple arrays--one each for

  • names
  • phone numbers
  • emails
  • addresses

These arrays must be local (passed via parameters) and not instance variables or objects.

You will probably want to store the data without the extra tabs and spaces that are included in the contacts.txt file---you need to trim away the whitespace, and you may not use string methods (like trim) to do this. You are also not allowed to use the string method contains() in this program.

You should output the contents of your arrays to several files using PrintStream. Here are examples for the sample contacts.txt:

  • addresses.txt - contains name/address pairs
  • emails.txt- contains name/email pairs
  • phones.txt- contains name/phone pairs
  • formatted_contacts.txt - contains a re-formatted address book entry that will be easier to read in next time.
these are the complete instructions JAVA Program that will read from a text file and split/store into
different arrays. This program will use line-based file processing to access each
line in the file, but will need to use token-based processing to

Instructions You are going to write a program that will read the contents of a virtual address book and split it out into multiple files. Address Book Entries Each entry will correspond to a single contact and will contain these entries: Name Phone Number Email Address The name is guaranteed to come first, but the other entries may appear in any order. You can trust that name, phone number, and email are each single-line entries, while address is a 3-line entry (following standard US formats). There may be extra newlines, tabs or spaces. Your program will use line-based file processing to access each line in the file, but will need to use token-based processing to figure out which type of information is being provided. contacts.txt The contents of all address book entries (one after the other) will be stored in a file called contacts.txt Storing the Data You should read the file in from contacts.txt and store the information in multiple arrays--one each for names phone numbers emails addresses These arrays must be local (passed via parameters) and not instance variables or objects. You will have a chance to redesign this project with objects later. Because you do not know ahead of time how many contacts you will need to read in, you will make an assumption about how big to set the size of your arrays--- this should be bigger than your test data. You will want to keep track of how many entries you actually read in, so you don't print parts of the array that haven't been initialized. One of my test inputs for grading this assignment will use a VERY VERY LARGE file as input. To get full style points, it should be really easy for me to change your program to have larger arrays. You will probably want to store the data without the extra tabs and spaces that are included in the contacts.txt file--- you need to trim away the whitespace, and you may not use string methods (like trim) to do this. You are also not allowed to use the string method contains() in this You should output the contents of your arrays to several files using PrintStream. Here are examples for the sample contacts.txt: addresses.txt - contains name/address pairs emails.txt - contains name/email pairs phones.txt - contains name/phone pairs formatted_contacts.txt - contains a re-formatted address book entry that will be easier to read in next time. Program Development You must break your program into a minimum of 4 methods, not including the main. Each method should accomplish a specific task and be appropriately named. . I recommend writing the program, focusing on reading the input into arrays first, then worry about output files and formatting. Worry about whitespace last. You may not print to any file while reading data from the file. Read in the entire file, then start printing. Forbidden fruit: o Objects and class variables (constants are okay) o whitespace-trimming string methods o string "contains" and "Split" methods o string builders Instructions You are going to write a program that will read the contents of a virtual address book and split it out into multiple files. Address Book Entries Each entry will correspond to a single contact and will contain these entries: Name Phone Number Email Address The name is guaranteed to come first, but the other entries may appear in any order. You can trust that name, phone number, and email are each single-line entries, while address is a 3-line entry (following standard US formats). There may be extra newlines, tabs or spaces. Your program will use line-based file processing to access each line in the file, but will need to use token-based processing to figure out which type of information is being provided. contacts.txt The contents of all address book entries (one after the other) will be stored in a file called contacts.txt Storing the Data You should read the file in from contacts.txt and store the information in multiple arrays--one each for names phone numbers emails addresses These arrays must be local (passed via parameters) and not instance variables or objects. You will have a chance to redesign this project with objects later. Because you do not know ahead of time how many contacts you will need to read in, you will make an assumption about how big to set the size of your arrays--- this should be bigger than your test data. You will want to keep track of how many entries you actually read in, so you don't print parts of the array that haven't been initialized. One of my test inputs for grading this assignment will use a VERY VERY LARGE file as input. To get full style points, it should be really easy for me to change your program to have larger arrays. You will probably want to store the data without the extra tabs and spaces that are included in the contacts.txt file--- you need to trim away the whitespace, and you may not use string methods (like trim) to do this. You are also not allowed to use the string method contains() in this You should output the contents of your arrays to several files using PrintStream. Here are examples for the sample contacts.txt: addresses.txt - contains name/address pairs emails.txt - contains name/email pairs phones.txt - contains name/phone pairs formatted_contacts.txt - contains a re-formatted address book entry that will be easier to read in next time. Program Development You must break your program into a minimum of 4 methods, not including the main. Each method should accomplish a specific task and be appropriately named. . I recommend writing the program, focusing on reading the input into arrays first, then worry about output files and formatting. Worry about whitespace last. You may not print to any file while reading data from the file. Read in the entire file, then start printing. Forbidden fruit: o Objects and class variables (constants are okay) o whitespace-trimming string methods o string "contains" and "Split" methods o string builders

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!