moyoloco09
moyoloco09

Reputation: 35

Why Eclipse IDE keeps throwing me the error "InputStreamReader cannot be resolved to a type"?

I'm writing this Java code using Eclipse to write on a file using BufferedReader to read from console. I need to instantiate an InputStreamReader as the parameter of BufferedReader. Here is my code:

package pruebaEscribirArchivo;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        final String FILE_NAME="HolaMundo.txt";
        File fileVar=new File(FILE_NAME);
        try {
            BufferedReader console=new BufferedReader(new InputStreamReader(System.in));
            PrintWriter file= new PrintWriter(new FileWriter(fileVar));
            file.close();
            console.close();
        }
        catch(IOException e){
            e.printStackTrace(System.err);
        }
    }
}

This gives me the error: "InputStreamReader cannot be resolved to a type" on line 8. My first guess was that I wasn't importing the class correctly. I tried

import java.io.InputStreamReader

instead of using the "*", but that doesn't worked. I don't know what could cause this problem. If you can tell what's wrong, please let me know. Thanks. :D

Upvotes: 0

Views: 91

Answers (0)

Related Questions