1 | : |
import java.io.FileInputStream;
|
2 | : |
import java.util.Iterator;
|
3 | : |
import org.apache.poi.poifs.filesystem.*;
|
4 | : |
|
5 | : |
public class PoiLs {
|
6 | : |
|
7 | : |
// 再帰的にファイルを探し、ファイル名を表示.
|
8 | : |
public static void printFiles(DirectoryEntry directory) {
|
9 | : |
Iterator it = directory.getEntries();
|
10 | : |
while( it.hasNext() ) {
|
11 | : |
Entry entry = (Entry)it.next();
|
12 | : |
if (entry.isDirectoryEntry()) {
|
13 | : |
printFiles((DirectoryEntry)entry);
|
14 | : |
}
|
15 | : |
else if (entry.isDocumentEntry()) {
|
16 | : |
System.out.println(entry.getName());
|
17 | : |
}
|
18 | : |
}
|
19 | : |
}
|
20 | : |
|
21 | : |
public static void main(String[] arg) throws Exception {
|
22 | : |
FileInputStream fin = new FileInputStream(arg[0]);
|
23 | : |
POIFSFileSystem fs = new POIFSFileSystem(fin);
|
24 | : |
DirectoryEntry root = fs.getRoot(); // ルートエントリの取得
|
25 | : |
printFiles(root);
|
26 | : |
fin.close();
|
27 | : |
}
|
28 | : |
}
|
29 | : |
|