diff --git a/src/main/java/org/RI/P1/AnalyzeDirectory.java b/src/main/java/org/RI/P1/AnalyzeDirectory.java index ffab465..fbfd025 100644 --- a/src/main/java/org/RI/P1/AnalyzeDirectory.java +++ b/src/main/java/org/RI/P1/AnalyzeDirectory.java @@ -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); } }