code: private DerInputStream init(boolean fullyBuffered, InputStream in)
              throws IOException {
  
          tag = (byte)in.read();
          byte lenByte = (byte)in.read();
          length = DerInputStream.getLength(lenByte, in);
          if (length == -1) { // indefinite length encoding found
              int readLen = in.available();
              int offset = 2;     // for tag and length bytes
              byte[] indefData = new byte[readLen + offset];
              indefData[0] = tag;
              indefData[1] = lenByte;
              DataInputStream dis = new DataInputStream(in);
              dis.readFully(indefData, offset, readLen);
              dis.close();
              DerIndefLenConverter derIn = new DerIndefLenConverter();
              in = new ByteArrayInputStream(derIn.convert(indefData));
              if (tag != in.read())
                  throw new IOException
                          ("Indefinite length encoding not supported");
              length = DerInputStream.getLength(in);
          }
  
          if (fullyBuffered && in.available() != length)
              throw new IOException("extra data given to DerValue constructor");
  
          byte[] bytes = IOUtils.readFully(in, length, true);
  
          buffer = new DerInputBuffer(bytes);
          return new DerInputStream(buffer);
      }
docs: /*
  helper routine