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,27 +26,40 @@ 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") {
data.getLinks();
} else {
usage();
}
System.out.println("--------------------------------------------------------------------------"); 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 { public static void main(String[] args) throws IOException, TikaException, SAXException {
if (args.length != 2) { if (args.length != 2) {
usage(); usage();
} }
String directory = args[0]; String directory = args[0];
String action = args[1];
readFiles(directory); readFiles(directory);
chooseAction(args[1]); chooseAction(action);
} }
} }