X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Fsupported%2FText.java;h=45b761a1f2e0fba52b91aff057a303086a40e134;hb=728191e896c89ded34228a0985af09eec0a83288;hp=252aca0443fbfe0f71db294c0c8c1d3a816deb72;hpb=cfdaf6052ddc5ca44cf19f1f6d9f154cc8443024;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/supported/Text.java b/src/be/nikiroo/fanfix/supported/Text.java index 252aca0..45b761a 100644 --- a/src/be/nikiroo/fanfix/supported/Text.java +++ b/src/be/nikiroo/fanfix/supported/Text.java @@ -100,10 +100,12 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); // Title - scan.next(); // Author (Date) - String chapter0 = scan.next(); // empty or Chapter 0 - while (chapter0.isEmpty()) { + if (scan.hasNext()) + scan.next(); // Title + if (scan.hasNext()) + scan.next(); // Author (Date) + String chapter0 = ""; + while (scan.hasNext() && chapter0.isEmpty()) { chapter0 = scan.next(); } @@ -126,15 +128,20 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - return scan.next(); + if (scan.hasNext()) + return scan.next(); + return ""; } private String getAuthor() { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); - String authorDate = scan.next(); + if (scan.hasNext()) + scan.next(); + String authorDate = ""; + if (scan.hasNext()) + authorDate = scan.next(); String author = authorDate; int pos = authorDate.indexOf('('); @@ -149,8 +156,11 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); - String authorDate = scan.next(); + if (scan.hasNext()) + scan.next(); + String authorDate = ""; + if (scan.hasNext()) + authorDate = scan.next(); String date = ""; int pos = authorDate.indexOf('('); @@ -227,9 +237,12 @@ class Text extends BasicSupport { @SuppressWarnings("resource") // cannot close, or we loose getInput()! Scanner scan = new Scanner(getInput(), "UTF-8"); scan.useDelimiter("\\n"); - scan.next(); // title - scan.next(); // author - scan.next(); // date or empty + if (scan.hasNext()) + scan.next(); // title + if (scan.hasNext()) + scan.next(); // author + if (scan.hasNext()) + scan.next(); // date or empty Boolean inChap = null; String line = ""; while (scan.hasNext()) {