Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend GedcomParser to accept String from GEDCOM file #182

Open
whatis777 opened this issue Feb 12, 2017 · 1 comment
Open

Extend GedcomParser to accept String from GEDCOM file #182

whatis777 opened this issue Feb 12, 2017 · 1 comment

Comments

@whatis777
Copy link

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.

@whatis777
Copy link
Author

PS: I solved my problem by passing an InputStream instead of the String representation. This preserves the content form being encoded...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant