I am creating a directory traversal application for sorting emails. It is a very simple app for my specific needs.
I would like to implement this by first traversing all the email files (there are 1000’s of them in a few directories) and make new directories based on the sent/received information inside the eml files (The sent or received name used will be decided based on a constant).
I was thinking something like this
public FileVisitResult visitFile(Path file,BasicFileAttributes attrs) {
email = getEmail(file);
emailSentRcievedName = sentRecievedName(email);
dirArray[currentDir + "\" + emailSentRecievedName] = file.get();
return CONTINUE;
}
The dirArray key:value will be used for the file moving implementation.
I know this array structure would work in Javascript but how would I implement this in Java?
Cheers.
Try using a hashmap. It gives you the ability to store pairs of data
Also take a look at this: SortedMap, maybe it helps you
http://docs.oracle.com/javase/1.4.2/docs/api/java/util/SortedMap.html
Javadoc api here: http://docs.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html