Search code examples
javabufferedreaderfilereader

How to give path to txt to read from in java?


I'm reading a txt with BuffererReader and I wonder how to give the path to my txt in BufferedReader's argument.

BufferedReader input = new Bufferedreader(
    new FileReader(D:VI.félév\Prog gyak\Project\proba.txt));

This doesn't seem to work.


Solution

  • Your problem is:

    new Filereader( .. )
    

    should be

    new FileReader( .. )
    

    And the path has to look like:

    new FileReader("D:\\directory\\proba.txt");
    

    You need an additional \ as escape character