Currently only a file or an input stream is accepted in the GedcomParser.load() method. If no GEDCOM file is available but only its content as String representation, then one cannot use the load() method directly.
If the string is wrapped by a BufferedInputStream (see code below) then the String seems to be invalid and cannot be used (see error message below).
Code:
BufferedInputStream stream = new BufferedInputStream(new ByteArrayInputStream(gedcomDataAsString.getBytes(StandardCharsets.UTF_8))); gp.load(stream);
Resulting error message:
Caused by: java.io.IOException: Does not appear to be a valid gedcom file - doesn't begin with a zero or newline in any supported encoding, and does not begin with a BOM marker for UTF-8 encoding.
at org.gedcom4j.io.reader.GedcomFileReader.getEncodingSpecificReader(GedcomFileReader.java:246)
at org.gedcom4j.io.reader.GedcomFileReader.(GedcomFileReader.java:104)
at org.gedcom4j.parser.GedcomParser.load(GedcomParser.java:313)
It would be very useful to have a load() method that can deal with a GEDCOM string.
Currently only a file or an input stream is accepted in the GedcomParser.load() method. If no GEDCOM file is available but only its content as String representation, then one cannot use the load() method directly.
If the string is wrapped by a BufferedInputStream (see code below) then the String seems to be invalid and cannot be used (see error message below).
Code:
BufferedInputStream stream = new BufferedInputStream(new ByteArrayInputStream(gedcomDataAsString.getBytes(StandardCharsets.UTF_8))); gp.load(stream);
Resulting error message: Caused by: java.io.IOException: Does not appear to be a valid gedcom file - doesn't begin with a zero or newline in any supported encoding, and does not begin with a BOM marker for UTF-8 encoding. at org.gedcom4j.io.reader.GedcomFileReader.getEncodingSpecificReader(GedcomFileReader.java:246) at org.gedcom4j.io.reader.GedcomFileReader.(GedcomFileReader.java:104)
at org.gedcom4j.parser.GedcomParser.load(GedcomParser.java:313)
It would be very useful to have a load() method that can deal with a GEDCOM string.