MCPcopy Create free account
hub / github.com/cschanck/single-file-java / source

Method source

src/main/java/org/sfj/StringsCompare.java:253–279  ·  view source on GitHub ↗

Source for a reader. @param r reader to draw from @return LineSource @throws IOException on underlying exception

(Reader r)

Source from the content-addressed store, hash-verified

251 * @throws IOException on underlying exception
252 */
253 public static LineSource source(Reader r) throws IOException {
254 BufferedReader br = new BufferedReader(r);
255 String first = br.readLine();
256 return new LineSource() {
257 String next = first;
258
259 @Override
260 public boolean hasLine() {
261 return next != null;
262 }
263
264 @Override
265 public String nextLine() throws IOException {
266 if (hasLine()) {
267 String p = next;
268 next = br.readLine();
269 return p;
270 }
271 throw new NoSuchElementException();
272 }
273
274 @Override
275 public void close() throws IOException {
276 r.close();
277 }
278 };
279 }
280
281 /**
282 * Source from a string.

Callers 10

testSimpleComparesMethod · 0.95
testArraySourcesMethod · 0.95
testIterableMethod · 0.95
testIteratorMethod · 0.95
testResourceMethod · 0.95
testReaderMethod · 0.95
testInputStreamMethod · 0.95
testFileMethod · 0.95
testSimpleMethod · 0.80
testRecursiveMethod · 0.80

Calls 2

readLineMethod · 0.45
iteratorMethod · 0.45

Tested by 10

testSimpleComparesMethod · 0.76
testArraySourcesMethod · 0.76
testIterableMethod · 0.76
testIteratorMethod · 0.76
testResourceMethod · 0.76
testReaderMethod · 0.76
testInputStreamMethod · 0.76
testFileMethod · 0.76
testSimpleMethod · 0.64
testRecursiveMethod · 0.64