To confirm that you are having a class with the name FileReader, just use the full class name in the code :
java.io.Reader fr = new java.io.FileReader("testfile.txt");
java.io.BufferedReader br = new java.io.BufferedReader(fr);
This will assure that you use the specific class and not a yourPackage.FileReader class.
Then, since only FileReader seems to be problematic, you can clean it a bit like :
import java.io.*
...
Reader fr = new java.io.FileReader("testfile.txt");
BufferedReader br = new BufferedReader(fr);
Only specifying the FileReader full name.
NOTE:
using Class.GetPackage, you should find out which class you are using.
System.out.println(FileReader.class.getPackage());
Explanation:
JLS - 7.5. Import Declarations
The scope and shadowing of a type or member imported by these declarations is specified in §6.3 and §6.4.
6.4.1. Shadowing
A package declaration never shadows any other declaration.
A single-type-import declaration d in a compilation unit c of package p that imports a type named n shadows, throughout c, the declarations of:
- any top level type named n declared in another compilation unit of p
- any type named n imported by a type-import-on-demand declaration in c
- any type named n imported by a static-import-on-demand declaration in c
Example
A
A.Run
A.Test
B
B.Test
In A.Run.java
System.out.println(Test.class.getPackage());
Here is the output :
- Without import : Package A
- Without import
import B.* : Package A
- Without import
import B.Test : Package B
FileReader, so that theFileReaderyour code refers to isn't actuallyjava.io.FileReader.Readerclass instead of aFileReaderclass ;) (The conversion would be equally infeasible...)I have used import java.io.*Well, show us the code. What you have there isn't enough.