VertexListInputStreamReader implements VertexListStream { @Override public boolean hasNextVertex() throws IOException { if (cacheValid) { return true; } else { for (String line = reader.readLine(); line != null; line = reader.readLine()) { line = line.trim(); if (line.isEmpty()) { continue; } String[] tokens = line.split(" "); try { cache.setId(Long.parseLong(tokens[0])); } catch (NumberFormatException ex) { throw new IOException("Failed to parse vertex identifier from stream.", ex); } if (cache.getValues().length == tokens.length - 1) { System.arraycopy(tokens, 1, cache.getValues(), 0, tokens.length - 1); } else { cache.setValues(Arrays.copyOfRange(tokens, 1, tokens.length)); } cacheValid = true; return true; } return false; } } VertexListInputStreamReader(InputStream inputStream); @Override boolean hasNextVertex(); @Override VertexData getNextVertex(); @Override void close();  }
@Test public void testHasNextVertexOnEmptyLines() throws IOException { String input = "\n \n \n"; InputStream inputStream = new ByteArrayInputStream(input.getBytes()); try (VertexListInputStreamReader reader = new VertexListInputStreamReader(inputStream)) { assertFalse(reader.hasNextVertex()); } }