home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2002 March / PCWMAR02.iso / software / windowsxp / ftgateoffice / ftgateoffice.exe / Main / webhelp0.cab / sitemap / MyBufferedInputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-11-07  |  848 b   |  44 lines

  1. package sitemap;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. public class MyBufferedInputStream {
  7.    InputStream m_is;
  8.    byte[] m_buffer = new byte[16384];
  9.    int m_nBufferCount = 0;
  10.    int m_nBytesRead = 0;
  11.  
  12.    private void RefreshBuffer() {
  13.       try {
  14.          this.m_nBytesRead = this.m_is.read(this.m_buffer);
  15.          this.m_nBufferCount = this.m_nBytesRead;
  16.       } catch (IOException var2) {
  17.          ((Throwable)var2).printStackTrace();
  18.          this.m_nBytesRead = 0;
  19.          this.m_nBufferCount = -1;
  20.       }
  21.    }
  22.  
  23.    public void close() throws IOException {
  24.       this.m_is.close();
  25.    }
  26.  
  27.    public MyBufferedInputStream(InputStream var1) {
  28.       this.m_is = var1;
  29.    }
  30.  
  31.    public int read() throws IOException {
  32.       if (this.m_nBufferCount == 0) {
  33.          this.RefreshBuffer();
  34.       }
  35.  
  36.       if (this.m_nBufferCount < 0) {
  37.          return -1;
  38.       } else {
  39.          this.m_nBufferCount += -1;
  40.          return this.m_buffer[this.m_nBytesRead - (this.m_nBufferCount + 1)] < 0 ? this.m_buffer[this.m_nBytesRead - (this.m_nBufferCount + 1)] + 256 : this.m_buffer[this.m_nBytesRead - (this.m_nBufferCount + 1)];
  41.       }
  42.    }
  43. }
  44.