k2k 5 Posting Whiz

hi, as far as I know if i wanna read external text document, i can either do:

BufferedReader reader = new BufferedReader(new FileReader("xxx.txt")); 

or 

Scanner reader = new Scanner(new File("xxx.txt"));

my first question is, what is the difference between BufferedReader and Scanner? And what is the difference between FileReader("xxx.txt") and just File("xxx.txt") Which one do most of the people use the most? I would rather know and stick with that one.

And I used Scanner one and it couldn't find the file. (I placed the text file in eclipse's src, bin and outside too // everywhere.. and it still cannot be found) Please give some suggestion. thanks.

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;


public class Namebody extends Name
{
	public static void main(String[] args)
	{
		Name nameHolder[] = new Name[350];
		
		int inID;
		String inLastname, inFirstname,inPhone;
		double inPrice;
	
		int count=0;
	
	
		Scanner reader = null;
	
	
		String filename="names.txt";
	
		try
		{
			reader = new Scanner(new FileReader(filename));
		}
	
		catch(FileNotFoundException e)
		{
			System.out.println("File not found!");
			System.exit(0);
		}
	
		while(reader.hasNextLine())
		{
			inID=reader.nextInt();
			inLastname= reader.next();
			inFirstname= reader.next();
			inPhone= reader.next();
			inPrice= reader.nextDouble();
		
			nameHolder[count].setName(inID, inLastname, inFirstname, inPhone, inPrice);
			count++;
		}
		
		for(int i=0; i<=count; i++)
		{
			nameHolder[i].output();
		}
		
	
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.