forked from 0xrumble/BytecodeScreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadUtil.java
More file actions
67 lines (64 loc) · 2.13 KB
/
ReadUtil.java
File metadata and controls
67 lines (64 loc) · 2.13 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package tools;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
public class ReadUtil {
public List<String> readToString(String file) {
List<String> strings = new ArrayList<>();
BufferedReader reader;
try {
reader = new BufferedReader(new FileReader(file));
String line = reader.readLine();
while (line != null) {
strings.add(line);
// read next line
line = reader.readLine();
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
return strings;
}
public static List<String> noRecursion(File dir, String types){
int fileNum=0,folderNum=0;
List<String> lists = new ArrayList<String>();
LinkedList<File> list=new LinkedList<File>();
File[] tempList = dir.listFiles();
for (int i = 0; i < tempList.length; i++) {
if (tempList[i].isFile()) {
if(tempList[i].toString().endsWith(types)) {
lists.add(tempList[i].toString());
}
}}
if(dir.exists()){
if (null==dir.listFiles()){
return null;
}
list.addAll(Arrays.asList(dir.listFiles()));
while(!list.isEmpty()){
File[] files = list.removeFirst().listFiles();
if(null==files){
continue;
}
for (File f:files) {
if (f.isDirectory()) {
list.add(f);
folderNum++;
} else {
if(f.getAbsolutePath().endsWith(types)){
lists.add(f.getAbsolutePath());
}
fileNum++;
}
}
}
}else{
System.out.println("文件不存在!");
}
//System.out.println("文件夹数量:" + folderNum + ",文件数量:" + fileNum);
return lists;
}
}