Fix action argument string matching
This commit is contained in:
parent
0f688eaf42
commit
bada55444e
|
@ -26,27 +26,40 @@ public class AnalyzeDirectory {
|
|||
System.exit(1);
|
||||
}
|
||||
|
||||
private static void chooseAction(String action) {
|
||||
private static void getMetadata() throws IOException, TikaException, SAXException {
|
||||
for (File file : files) {
|
||||
FileData data = new FileData(file);
|
||||
if (action == "metadata") {
|
||||
System.out.println(data);
|
||||
} else if (action == "links") {
|
||||
data.getLinks();
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
System.out.println(data);
|
||||
System.out.println("--------------------------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
private static void getAllLinks() throws IOException, TikaException, SAXException {
|
||||
for (File file : files) {
|
||||
FileData data = new FileData(file);
|
||||
data.getLinks();
|
||||
System.out.println("--------------------------------------------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
private static void chooseAction(String action) throws IOException, TikaException, SAXException {
|
||||
if (action.equals("metadata")) {
|
||||
getMetadata();
|
||||
} else if (action.equals("links")) {
|
||||
getAllLinks();
|
||||
} else {
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, TikaException, SAXException {
|
||||
if (args.length != 2) {
|
||||
usage();
|
||||
}
|
||||
String directory = args[0];
|
||||
String action = args[1];
|
||||
readFiles(directory);
|
||||
chooseAction(args[1]);
|
||||
chooseAction(action);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue