X-Git-Url: http://git.nikiroo.be/?p=nikiroo-utils.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fserial%2FImporter.java;h=810d694db5a316a4aca1290b5b31650312005f0d;hp=eec30b24b754b248c9ebf55af950cefa1d4c97cf;hb=23cf894daa02843da6e6f1b199eaaea29a739f81;hpb=e838eb0ef7ce247c2d3adbc1e01e8aef9161b125 diff --git a/src/be/nikiroo/utils/serial/Importer.java b/src/be/nikiroo/utils/serial/Importer.java index eec30b2..810d694 100644 --- a/src/be/nikiroo/utils/serial/Importer.java +++ b/src/be/nikiroo/utils/serial/Importer.java @@ -75,11 +75,18 @@ public class Importer { if (in == null) { throw new NullPointerException("InputStream is null"); } - if (stream.eof()) { - throw new NullPointerException("InputStream is empty"); - } + boolean first = true; while (stream.next()) { + if (stream.eof()) { + if (first) { + throw new NullPointerException( + "InputStream empty, normal termination"); + } + return this; + } + first = false; + boolean zip = stream.startsWiths("ZIP:"); boolean b64 = stream.startsWiths("B64:"); @@ -142,6 +149,10 @@ public class Importer { // TODO use the stream, Luke String line = IOUtils.readSmallStream(in); + if (line.isEmpty()) { + return false; + } + if (line.equals("{")) { // START: new child if needed if (link != null) { child = new Importer(map); @@ -160,7 +171,12 @@ public class Importer { } else { if (line.endsWith(":")) { // construct - me = SerialUtils.createObject(type); + try { + me = SerialUtils.createObject(type); + } catch (NoSuchMethodException e) { + System.out.println("LINE: <" + line + ">"); + throw e; + } } else { // direct value int pos = line.indexOf(":");