Add Parser class

This commit is contained in:
coolneng 2020-11-17 19:14:35 +01:00
parent 3f664c8099
commit 300b7b78ee
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
3 changed files with 42 additions and 0 deletions

5
.gitignore vendored
View File

@ -1 +1,6 @@
data
target
.classpath
.project
.settings
output

View File

@ -29,6 +29,11 @@
<artifactId>lucene-analyzers-common</artifactId>
<version>8.6.3</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,32 @@
package org.RI.P2;
import java.util.List;
import java.io.IOException;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Collectors;
public class Parser {
private static List<File> files;
private static void readFiles(String directory) throws IOException {
files = Files.walk(Paths.get(directory)).filter(Files::isRegularFile).map(Path::toFile)
.collect(Collectors.toList());
}
private static void usage() {
System.out.println("Usage: Parser <directory>");
System.out.println("option directory: directory that contains JSON files");
System.exit(1);
}
public static void main(String[] args) throws IOException {
if (args.length != 1) {
usage();
}
String directory = args[0];
readFiles(directory);
}
}