Fix action argument string matching

This commit is contained in:
coolneng 2020-10-25 22:21:10 +01:00
parent 0f688eaf42
commit bada55444e
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
1 changed files with 22 additions and 9 deletions

View File

@ -26,18 +26,30 @@ public class AnalyzeDirectory {
System.exit(1); System.exit(1);
} }
private static void chooseAction(String action) { private static void getMetadata() throws IOException, TikaException, SAXException {
for (File file : files) { for (File file : files) {
FileData data = new FileData(file); FileData data = new FileData(file);
if (action == "metadata") {
System.out.println(data); System.out.println(data);
} else if (action == "links") { System.out.println("--------------------------------------------------------------------------");
}
}
private static void getAllLinks() throws IOException, TikaException, SAXException {
for (File file : files) {
FileData data = new FileData(file);
data.getLinks(); 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 { } else {
usage(); usage();
} }
System.out.println("--------------------------------------------------------------------------");
}
} }
public static void main(String[] args) throws IOException, TikaException, SAXException { public static void main(String[] args) throws IOException, TikaException, SAXException {
@ -45,8 +57,9 @@ public class AnalyzeDirectory {
usage(); usage();
} }
String directory = args[0]; String directory = args[0];
String action = args[1];
readFiles(directory); readFiles(directory);
chooseAction(args[1]); chooseAction(action);
} }
} }