commons-file/src/main/java/info/monitorenter/cpdetector/io/JChardetFacade.java
public synchronized Charset detectCodepage(InputStream in, int length) throws IOException {
    this.Reset();
    int len;
    int read = 0;
    boolean done = false;
    boolean isAscii = true;
    Charset ret = null;
    do {
      len = in.read(buf, 0, Math.min(buf.length, length - read));
      if (len > 0) {
        read += len;
      }
      if (!done)
        done = det.DoIt(buf, len, false);
    } while (len > 0 && !done);
    det.DataEnd();
    if (this.codpage == null) {
      if (this.m_guessing) {
        ret = guess();
      } else {
        ret = UnknownCharset.getInstance();
      }
    } else {
      ret = this.codpage;
    }
    return ret;

  }
public synchronized Charset detectCodepage(InputStream in, int length) throws IOException {
    this.Reset();
    int len;
    int read = 0;
    boolean done = false;
    boolean isAscii = true;
    Charset ret = null;
    do {
      len = in.read(buf, 0, Math.min(buf.length, length - read));
      if (len > 0) {
        read += len;
      }
      if (!done)
        done = det.DoIt(buf, len, false);
    } while (len > 0 && !done);
    det.DataEnd();
    if (this.codpage == null) {
      if (this.m_guessing) {
        ret = guess();
      } else {
        ret = UnknownCharset.getInstance();
      }
    } else {
      ret = this.codpage;
    }
    return ret;

  }
public synchronized Charset detectCodepage ( InputStream in , int length ) throws IOException { this . Reset ( ) ; int len ; int read = 0 ; boolean done = false ; boolean isAscii = true ; Charset ret = null ; do { len = in . read ( buf , 0 , Math . min ( buf . length , length - read ) ) ; if ( len > 0 ) { read += len ; } if ( ! done ) done = det . DoIt ( buf , len , false ) ; } while ( len > 0 && ! done ) ; det . DataEnd ( ) ; if ( this . codpage == null ) { if ( this . m_guessing ) { ret = guess ( ) ; } else { ret = UnknownCharset . getInstance ( ) ; } } else { ret = this . codpage ; } return ret ; }
/*
(non-Javadoc)

@see cpdetector.io.ICodepageDetector#detectCodepage(java.io.InputStream)
/ * ( non - Javadoc )