Fix StringIndexOutOfBoundsException when scraped page is empty.

This commit is contained in:
Andreas Schildbach 2014-08-09 14:16:31 +02:00
parent 4c17bf10eb
commit e897787d09

View file

@ -263,6 +263,8 @@ public final class ParserUtils
is.mark(PEEK_SIZE);
final byte[] firstBytes = new byte[PEEK_SIZE];
final int read = is.read(firstBytes);
if (read == -1)
return "";
is.reset();
return new String(firstBytes, 0, read).replaceAll("\\p{C}", "");
}