ArrayList<String> contactInfo = new ArrayList<String>(); // ArrayList to hold information
try
{
File read = new File("contactlist.txt");
Scanner in = new Scanner(new File("contactlist.txt")); // scanner to read in the txt file
FileInputStream fis = new FileInputStream(read);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
String name = "";
String pNumber = "";
//ArrayList<String> contactInfo = new ArrayList<String>(); // ArrayList to hold information
while(in.hasNextLine()) // Loops through until the txt file is done
{
name = in.next() + " " + in.next(); // Gets the first name then adds space and Last name
pNumber = in.next(); // gets the Phone Number
in.nextLine(); // clears buffer to next line
contactInfo.add(name); contactInfo.add(pNumber);
}
}
catch(IOException e)
{
System.out.println("************** Error *****>>>>>>");
System.out.println("* This File is unexisting or unreadable");
}
This post has been edited by putha-nee: 11 November 2009 - 01:29 PM

New Topic/Question
Reply




MultiQuote









|