Click here to Skip to main content
15,898,984 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am getting the following error when trying to compile my program.

'(' or '[' Expected.

Java
Scanner s1 = new Scanner ( new FileReader ("students.txt"));
Posted
Updated 11-Mar-13 6:22am
v2
Comments
Richard C Bishop 11-Mar-13 10:31am    
Try removing the space between Scanner and (new FileReader()); The parenthesis should be right up against it.

1 solution

It should be File and not FileReader.

Try:
C#
Scanner sc = new Scanner( new File("students.txt"));

Refer: java.util.Scanner[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900