public byte[] put(InputStream in) throws IOException {
  ByteArrayOutputStream id=new ByteArrayOutputStream();
  int level=0;
  try {
    while (true) {
      if (put(id,in,level)) {
        break;
      }
      if (id.size() > maxBlockSize / 2) {
        id=putIndirectId(id);
        level++;
      }
    }
  }
 catch (  IOException e) {
    remove(id.toByteArray());
    throw e;
  }
  if (id.size() > minBlockSize * 2) {
    id=putIndirectId(id);
  }
  return id.toByteArray();
}

public byte [ ] put ( InputStream in ) throws IOException { ByteArrayOutputStream id = new ByteArrayOutputStream ( ) ; int level = 0 ; try { while ( true ) { if ( put ( id , in , level ) ) { break ; } if ( id . size ( ) > maxBlockSize / 2 ) { id = putIndirectId ( id ) ; level ++ ; } } } catch ( IOException e ) { remove ( id . toByteArray ( ) ) ; throw e ; } if ( id . size ( ) > minBlockSize * 2 ) { id = putIndirectId ( id ) ; } return id . toByteArray ( ) ; }
store the stream , and return the id . the stream is not closed .
