container/src/main/java/com/streamsets/datacollector/bundles/SupportBundleManager.java
private int readFully(InputStream inputStream, byte []buffer) throws IOException {
    int readBytes = 0;

    while(readBytes < buffer.length) {
      int loaded = inputStream.read(buffer, readBytes, buffer.length - readBytes);
      if(loaded == -1) {
        return readBytes == 0 ? -1 : readBytes;
      }

      readBytes += loaded;
    }

    return readBytes;
  }
private int readFully(InputStream inputStream, byte []buffer) throws IOException {
    int readBytes = 0;

    while(readBytes < buffer.length) {
      int loaded = inputStream.read(buffer, readBytes, buffer.length - readBytes);
      if(loaded == -1) {
        return readBytes == 0 ? -1 : readBytes;
      }

      readBytes += loaded;
    }

    return readBytes;
  }
private int readFully ( InputStream inputStream , byte [ ] buffer ) throws IOException { int readBytes = 0 ; while ( readBytes < buffer . length ) { int loaded = inputStream . read ( buffer , readBytes , buffer . length - readBytes ) ; if ( loaded == - 1 ) { return readBytes == 0 ? - 1 : readBytes ; } readBytes += loaded ; } return readBytes ; }
This method will read from the input stream until the whole buffer is loaded up with actual bytes or end of stream
has been reached. Hence it will return buffer.length of all executions except the last two - one to the last call
will return less then buffer.length (reminder of the data) and returns -1 on any subsequent calls.
This method will read from the input stream until the whole buffer is loaded up with actual bytes or end of stream has been reached . Hence it will return buffer . length of all executions except the last two - one to the last call will return less then buffer . length ( reminder of the data ) and returns - 1 on any subsequent calls .