示例#1
0
文件: IO.java 项目: nremond/boon
  public static CharBuf read(Reader input, CharBuf charBuf, final int bufSize) {

    if (charBuf == null) {
      charBuf = CharBuf.create(bufSize);
    } else {
      charBuf.readForRecycle();
    }

    try {

      char[] buffer = charBuf.toCharArray();
      int size = input.read(buffer);
      if (size != -1) {
        charBuf._len(size);
      }
      if (size < buffer.length) {
        return charBuf;
      }

      copy(input, charBuf);

    } catch (IOException e) {
      Exceptions.handle(e);
    } finally {
      try {
        input.close();
      } catch (IOException e) {
        Exceptions.handle(e);
      }
    }

    return charBuf;
  }
示例#2
0
文件: IO.java 项目: nremond/boon
  public static char[] readCharBuffer(Reader input) {

    try {
      CharBuf sw = CharBuf.create(DEFAULT_BUFFER_SIZE);
      copy(input, sw);
      return sw.toCharArray();

    } finally {
      try {
        input.close();
      } catch (IOException e) {
        Exceptions.handle(e);
      }
    }
  }