-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGZipAllFiles.java
More file actions
32 lines (26 loc) · 792 Bytes
/
GZipAllFiles.java
File metadata and controls
32 lines (26 loc) · 792 Bytes
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
import java.io.*;
import java.util.concurrent.*;
public class GZipAllFiles {
public final static int THREAD_COUNT = 4;
public static void main(String[] args) {
ExecutorService pool = Executors.newFixedThreadPool(THREAD_COUNT);
for (String filename : args) {
File f = new File(filename);
if (f.exists()) {
if (f.isDirectory()) {
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) {
if (!files[i].isDirectory()) { // don't recurse directories
Runnable task = new GZipRunnable(files[i]);
pool.submit(task);
}
}
} else {
Runnable task = new GZipRunnable(f);
pool.submit(task);
}
}
}
pool.shutdown();
}
}