EdgeListInputStreamReader implements EdgeListStream { @Override public boolean hasNextEdge() 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(" "); if (tokens.length < 2) { throw new IOException("Malformed edge data in stream: \"" + line + "\"."); } try { cache.setSourceId(Long.parseLong(tokens[0])); cache.setDestinationId(Long.parseLong(tokens[1])); } catch (NumberFormatException ex) { throw new IOException("Failed to parse vertex identifier from stream.", ex); } if (cache.getValues().length == tokens.length - 2) { System.arraycopy(tokens, 2, cache.getValues(), 0, tokens.length - 2); } else { cache.setValues(Arrays.copyOfRange(tokens, 2, tokens.length)); } cacheValid = true; return true; } return false; } } EdgeListInputStreamReader(InputStream inputStream); @Override boolean hasNextEdge(); @Override EdgeData getNextEdge(); @Override void close();  }
@Test public void testHasNextEdgeOnEmptyLines() throws IOException { String input = "\n \n \n"; InputStream inputStream = new ByteArrayInputStream(input.getBytes()); try (EdgeListInputStreamReader reader = new EdgeListInputStreamReader(inputStream)) { assertFalse(reader.hasNextEdge()); } }