I was hoping someone could give me the code to read and then to system print out the words in the text file.

The textfile contains:
One,
Two,
Three,

I'm new to IO readers so this would help alot as I'm having trouble reprinting the information out.

Recommended Answers

All 2 Replies

Google java read text file then google System.out.println

try {
	BufferedReader read= new BufferedReader(new FileReader
					           (new File("fileToRead.txt")));
	Scanner fileReader = new Scanner(read);
		
	while(fileReader.hasNext()){
		System.out.println(fileReader.nextLine();			
	}
	fileReader.close();
}catch (FileNotFoundException fileNotFound) {
} catch (IOException ioEx){}
commented: Don't give people code -1
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.