Line 20 (if (filename.matches()))is breaking the code cause i have been passing "name" which is a string it . Any suggestions please
import java.io.*;
import java.nio.file.Path;
import com.opencsv.CSVReader;
import java.io.FileReader;
import java.util.Arrays;
import java.util.List;
class CsvToArray {
public static void main(String [] args){
//Directory
File directory = new File("C:\\Users\\person\\source\\Java\\");
//store all files in the directory
File[] containingFileNames = directory.listFiles();
//check to make sure that the list is not empty
if (containingFileNames != null && containingFileNames.length>0)
{
//now iterate through the files
for (File fileName : containingFileNames)
{
if (fileName.matches())
{
//Use bufferedReader class to read the file
BufferedReader reader = new BufferedReader(new FileReader(fileName));
System.out.println(reader);
}
}
}
}
}