-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyFileClass.java
40 lines (34 loc) · 1.13 KB
/
MyFileClass.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.io.File;
/**
* Created by Tester on 27/12/2016.
*/
public class MyFileClass {
static String path = "";
String find(Folder folder, String filename){
String pathToFile = "";
String[] list = folder.file.list();
try {
for (String name : list) {
if (folder.isDir) {
if (name.equals(filename)) {
pathToFile = folder.path + "\\" + filename;
path = pathToFile;
return pathToFile;
} else {
String sub = folder.path + "\\" + name;
Folder subfolder = new Folder(sub);
if (subfolder.isDir) {
find(subfolder, filename);
}
}
}
}
}catch(NullPointerException e){
//file not found
}
if(path.equals("")) {
path = "Incorrect dir or no such file in this directory and subdirectory";
}
return path;
}
}