Exemplo n.º 1
0
  private String readLine4Big() throws Exception {
    byte[] b = new byte[1024 * 256];

    int i = 0;
    int readLen = 0;
    while ((readLen = bis.read(b, 0, 1024 * 256)) != -1) {

      if (readLen == 1) {
        if (b[0] == 10) {
          break;
        } else if (b[0] != 13) {
          this.bos.write(b, 0, readLen);
        }
      } else if (b[readLen - 2] != 13 && b[readLen - 1] != 10) {
        this.bos.write(b, 0, readLen);
      } else if (b[readLen - 1] == 10) {
        if (b[readLen - 2] == 13) {
          this.bos.write(b, 0, (readLen - 2));
        } else {
          this.bos.write(b, 0, (readLen - 1));
        }
        break;
      }
    }

    String ret = this.bos.toString();
    this.bos.reset();
    return ret;
  }
Exemplo n.º 2
0
  public int read(byte[] buf) throws Exception {

    for (int i = 0; i < buf.length; i++) {
      bis.read(buf, i, 1);
    }

    return buf.length;
  }
Exemplo n.º 3
0
  private String readLine4Small() throws Exception {
    this.b[0] = (byte) 0;

    int i = 0;
    while (bis.read(this.b, 0, 1) != -1) {

      if (this.b[0] != 13 && this.b[0] != 10) {
        this.bos.write(this.b, 0, 1);
      } else if (this.b[0] == 10) {
        break;
      }
    }

    String ret = this.bos.toString();
    this.bos.reset();
    return ret;
  }