-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathTest.java
More file actions
65 lines (56 loc) · 1.96 KB
/
Test.java
File metadata and controls
65 lines (56 loc) · 1.96 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
package example;
import java.util.Vector;
import com.pff.PSTException;
import com.pff.PSTFile;
import com.pff.PSTFolder;
import com.pff.PSTMessage;
public class Test {
public static void main(final String[] args) {
new Test(args[0]);
}
public Test(final String filename) {
try {
final PSTFile pstFile = new PSTFile(filename);
System.out.println(pstFile.getMessageStore().getDisplayName());
this.processFolder(pstFile.getRootFolder());
} catch (final Exception err) {
err.printStackTrace();
}
}
int depth = -1;
public void processFolder(final PSTFolder folder) throws PSTException, java.io.IOException {
this.depth++;
// the root folder doesn't have a display name
if (this.depth > 0) {
this.printDepth();
System.out.println(folder.getDisplayName());
}
// go through the folders...
if (folder.hasSubfolders()) {
final Vector<PSTFolder> childFolders = folder.getSubFolders();
for (final PSTFolder childFolder : childFolders) {
this.processFolder(childFolder);
}
}
// and now the emails for this folder
if (folder.getContentCount() > 0) {
this.depth++;
PSTMessage email = (PSTMessage) folder.getNextChild();
while (email != null) {
if (!email.getMessageClass().equals("IPM.Note")) {
this.printDepth();
System.out.println("Email: [" + email.getMessageClass() + "]" + email.getDescriptorNodeId() + " - " + email.getSubject());
}
email = (PSTMessage) folder.getNextChild();
}
this.depth--;
}
this.depth--;
}
public void printDepth() {
for (int x = 0; x < this.depth - 1; x++) {
System.out.print(" | ");
}
System.out.print(" |- ");
}
}