code: public static long copyContentIntoOutputStream(InputStream source, OutputStream target, int bufferSize,
                                                     boolean readToEOF) throws IOException {
          byte[] tempBuf = new byte[Math.max(ONE_KB, bufferSize)];  // at least a 1k buffer
          long bytesWritten = 0;
          while (true) {
              int bytesRead = source.read(tempBuf);
              if (bytesRead < 0) {
                  break;
              }
              target.write(tempBuf, 0, bytesRead);
              bytesWritten += bytesRead;
              if (!readToEOF) {
                  // prevents us from reading more than 1 buffer worth
                  break;
              }
  
          }
          return bytesWritten;
      }
docs: the real work-horse behind most of these methods
  @param source     the source InputStream from which to read the data (not closed when done)
  @param target     the target OutputStream to which to write the data (not closed when done)
  @param bufferSize the size of the transfer buffer to use
  @param readToEOF  if we should read to end-of-file of the source (true) or just 1 buffer's worth (false)
  @throws IOException