Add possibility to parse a String to parser

This commit is contained in:
JanUlrich 2017-07-05 17:52:23 +02:00
parent 0ad97251ca
commit 2167a4288e

View File

@ -9,6 +9,7 @@ import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
@ -40,4 +41,8 @@ public class JavaTXParser {
public SourceFile parse(File file) throws IOException, ClassNotFoundException {
return this.parse(new FileInputStream(file));
}
public SourceFile parse(String fileContent) throws IOException, ClassNotFoundException {
return this.parse(new ByteArrayInputStream(fileContent.getBytes(StandardCharsets.UTF_8)));
}
}