BufferedReader from only some bytes of InputStream

I have an InputStream that I would like to read in concurrently. As such I do some logic to figure out for each thread what the

long start = // byte number for thread to start working on
long end = // byte number for thread to end working on

And then I want some way to do a computation starting on byte number start and ending on byte number end. I know I can use InputStream.skip(start) for the first part, but how do I stop a process after byte end?

public void logic(long start, long end) {
   InputStream is = new FileInputStream(file);
   // stop at is.byteNumber == end - don't know how to do this


    public void doComputation(is) {
       try(BufferedReader br = new BufferedReader(new InputStreamReader(is))) { 
           //do things line by line

Any and all help would be appreciate.

1 answer