FastJavaIO icon indicating copy to clipboard operation
FastJavaIO copied to clipboard

Add a hasNext

Open pathikrit opened this issue 7 years ago • 4 comments

Can you simply add boolean hasNext() {return num_bytes_read != -1;} ? This way I can fuzzy benchmark it - else your code throws exceptions in the end.

pathikrit avatar May 23 '17 21:05 pathikrit

This seems like a good idea. I'll make the change and add the appropriate tests this week to make sure it doesn't break anything.

williamfiset avatar May 23 '17 23:05 williamfiset

While you are it, can you also add a constructor that accepts a BufferedReader too? Also you might want to implement some interface (e.g. Reader or InputStream) from the JDK.

pathikrit avatar May 24 '17 03:05 pathikrit

The InputReader currently supports an java.io.InputStream as well as an optional buffer size for the given input stream, I'll update the README soon as I can. I mistakingly thought the BufferedReader implemented the InputStream interface, but apparently, it does not. I'll open an issue to include the java.io.Reader interface, because why not?

williamfiset avatar May 25 '17 03:05 williamfiset

When you are designing a scanner like this, you want to take in a Reader at the end of the day since you can go to InputStream to a Reader but not other way.

pathikrit avatar May 25 '17 13:05 pathikrit