Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,29 @@
|
|||
import java.io.File;
|
||||
|
||||
public class MainEntry {
|
||||
public static void main(String[] args) {
|
||||
walkin(new File("/home/user")); //Replace this with a suitable directory
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function to descend into the directory tree and find all the files
|
||||
* that end with ".mp3"
|
||||
* @param dir A file object defining the top directory
|
||||
**/
|
||||
public static void walkin(File dir) {
|
||||
String pattern = ".mp3";
|
||||
|
||||
File listFile[] = dir.listFiles();
|
||||
if (listFile != null) {
|
||||
for (int i=0; i<listFile.length; i++) {
|
||||
if (listFile[i].isDirectory()) {
|
||||
walkin(listFile[i]);
|
||||
} else {
|
||||
if (listFile[i].getName().endsWith(pattern)) {
|
||||
System.out.println(listFile[i].getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class WalkTree {
|
||||
public static void main(String[] args) throws IOException {
|
||||
Path start = FileSystems.getDefault().getPath("/path/to/file");
|
||||
Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file,
|
||||
BasicFileAttributes attrs) throws IOException {
|
||||
if (file.toString().endsWith(".mp3")) {
|
||||
System.out.println(file);
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
|
||||
public class WalkTree {
|
||||
public static void main(String[] args) throws IOException {
|
||||
Path start = FileSystems.getDefault().getPath("/path/to/file");
|
||||
Files.walk(start)
|
||||
.filter( path -> path.toFile().isFile())
|
||||
.filter( path -> path.toString().endsWith(".mp3"))
|
||||
.forEach( System.out::println );
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue