0

Is there an easy way to go through an entire directory recursively to find all CSV files? In python, there's os.walk and I see that Java has FileVisitor, but I have no idea how to use it correctly (http://download.oracle.com/javase/tutorial/essential/io/walk.html).

What I want to do is something like this (pseudocode):

mainDirectory = r'C:\Downloads\MyFolder'
// Must work for directories within mainDirectory
for (file : mainDirectory){
    if (filename.find('csv') > -1){
        callMyMethod(filesrc)}
}

Can someone help me convert this into actual Java code? Thanks a lot!

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by peter_budo
0

for example

for (int i = 0, n = file; i < n; i++) {
   if (file[i].toString().contains(".cvs")) {...
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.