Skip to content
Advertisement

Read files from directory using BufferedReader

I wrote a code to read a files from a directory. The directory contain many files. Firstly, I count the number of the files in the directory, then I would like to count number of lines in the files that have as extension: .info and .data

My code is the following:

JavaScript

I got as error:

JavaScript

The error concerns the FileReader, it accept only the string, and the filename is a String

Do you have some idea please ? Thank you

Advertisement

Answer

Instead of passing filename in FileReader(), try passing file.

JavaScript

My answer assumes that the error that you have given as output is stack trace printed in the try-catch block and not the error that you get when you try to compile/run the code.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement