java - Regex that matches files in passed in folder -


i have list of files

a/b/c a/b/c.data a/b/c/d a/b/c/d.data

when pass in folder path a/b/, want return list of strings of files in folder. in case, a/b/c , a/b/c.data should returned. have tried (a\/b\/).+(?!\/) string.matches(<regex>) returns true them.

ps: file name doesn't end /.

try using files.walk

files   .walk(paths.get("your_path"))   .foreach(system.out::println); 

if want files this:

files    .walk(paths.get("your_path"))    .map(path::tofile)             // convert paths files    .filter(file::isfile)          // filter remove directories    .map(file::tostring)           // convert files strings    .collect(collectors.tolist()); // return list of strings 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -