code: public static Recorder wrapInputStreamWithHttpRecord(File dir,
          String basename, InputStream in, String encoding)
      throws IOException {
          Recorder rec = new Recorder(dir, basename);
          if (encoding != null && encoding.length() > 0) {
              rec.setCharset(Charset.forName(encoding));
          }
          // Do not use FastBufferedInputStream here.  It does not
          // support mark.
          InputStream is = rec.inputWrap(new BufferedInputStream(in));
          final int BUFFER_SIZE = 1024 * 4;
          byte [] buffer = new byte[BUFFER_SIZE];
          while(true) {
              // Just read it all down.
              int x = is.read(buffer);
              if (x == -1) {
                  break;
              }
          }
          is.close();
          return rec;
      }
docs: Record the input stream for later playback by an extractor, etc.
  This is convenience method used to setup an artificial HttpRecorder
  scenario used in unit tests, etc.
  @param dir Directory to write backing file to.
  @param basename of what we're recording.
  @param in Stream to read.
  @param encoding Stream encoding.
  @throws IOException
  @return An {@link org.archive.util.Recorder}.