按行读取UTF-8编码数据，针对每行的数据做处理

@param in {@link InputStream}
@param lineHandler 行处理接口，实现handle方法用于编辑一行的数据后入到指定地方
@throws IORuntimeException IO异常
@since 3.1.1
557184
public static void readUtf8Lines(InputStream in, LineHandler lineHandler) throws IORuntimeException {
		readLines(in, CharsetUtil.CHARSET_UTF_8, lineHandler);
	}
78961
public static String readTextAsString(DataInput in) throws IOException {
    int bufLen = (int)readVLong(in);
    byte[] buf = new byte[bufLen];
    in.readFully(buf);

    return new String(buf, StandardCharsets.UTF_8);
  }
1185198
public static ObjectStream<String> readFileIntoMarkableStreamFactory(
      final String infile) {

    InputStreamFactory inputStreamFactory = null;
    try {
      inputStreamFactory = new MarkableFileInputStreamFactory(new File(infile));
    } catch (final FileNotFoundException e) {
      e.printStackTrace();
    }
    ObjectStream<String> lineStream = null;
    try {
      lineStream = new PlainTextByLineStream(inputStreamFactory, "UTF-8");
    } catch (final IOException e) {
      CmdLineUtil.handleCreateObjectStreamError(e);
    }
    return lineStream;
  }
33540
public static int readLength(InputStream in) throws IOException, EOFException {
        int b0 = in.read();
        if (b0 < 0) {
            throw new EOFException();
        }
        if (b0 <= 0x7f) {
            return b0;
        }
        int b1 = in.read();
        if (b1 < 0) {
            throw new EOFException();
        }
        if (b0 <= 0xbf) {
            return ((b0 & 0x3f) << 8) | b1;
        }
        int b2 = in.read();
        if (b2 < 0) {
            throw new EOFException();
        }
        if (b0 <= 0xdf) {
            return ((b0 & 0x1f) << 16) | (b1 << 8) | b2;
        }
        int b3 = in.read();
        if (b3 < 0) {
            throw new EOFException();
        }
        if (b0 <= 0xef) {
            return ((b0 & 0x0f) << 24) | (b1 << 16) | (b2 << 8) | b3;
        }
        int b4 = in.read();
        if (b4 < 0) {
            throw new EOFException();
        }
        return (b1 << 24) | (b2 << 16) | (b3 << 8) | b4;
    }
1217718
public static String readLine(InputStream in, String charset) throws IOException
    {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        while (true)
        {
            // Read one byte from the stream.
            int b = in.read();

            // If the end of the stream was reached.
            if (b == -1)
            {
                if (baos.size() == 0)
                {
                    // No more line.
                    return null;
                }
                else
                {
                    // The end of the line was reached.
                    break;
                }
            }

            if (b == '\n')
            {
                // The end of the line was reached.
                break;
            }

            if (b != '\r')
            {
                // Normal character.
                baos.write(b);
                continue;
            }

            // Read one more byte.
            int b2 = in.read();

            // If the end of the stream was reached.
            if (b2 == -1)
            {
                // Treat the '\r' as a normal character.
                baos.write(b);

                // The end of the line was reached.
                break;
            }

            // If '\n' follows the '\r'.
            if (b2 == '\n')
            {
                // The end of the line was reached.
                break;
            }

            // Treat the '\r' as a normal character.
            baos.write(b);

            // Append the byte which follows the '\r'.
            baos.write(b2);
        }

        // Convert the byte array to a string.
        return baos.toString(charset);
    }
258813
public static String readLine(InputStream in, byte[] buffer)
        throws IllegalArgumentException, IOException
    {
        return readLine(in, buffer, -1);
    }
376210
public static byte[] readLine(InputStream in) throws IOException {
		int BUFF_LENGTH = 256;
		byte[] buf = new byte[BUFF_LENGTH];

		int i = 0;
		int loops = 0;
		int ch = 0;

		while (true) {
			ch = in.read();
			if (ch < 0) {
				break;
			}
			loops++;

			// skip a leading LF's
			if (loops == 1 && ch == LF) {
				continue;
			}

			if (ch == CR || ch == LF) {
				break;
			}

			if (i >= buf.length) {
				byte[] oldBuf = buf;
				buf = new byte[oldBuf.length + BUFF_LENGTH];
				System.arraycopy(oldBuf, 0, buf, 0, oldBuf.length);
			}
			buf[i++] = (byte) ch;
		}

		if (ch == -1 && i == 0) {
			return null;
		}

		// skip a trailing LF if it exists
		if (ch == CR && in.available() >= 1 && in.markSupported()) {
			in.mark(1);
			ch = in.read();
			if (ch != LF) {
				in.reset();
			}
		}

		byte[] oldBuf = buf;
		buf = new byte[i];
		System.arraycopy(oldBuf, 0, buf, 0, i);

		return buf;
	}
858301
public static Writer getOutputStreamWriter(OutputStream out) {
    try {
      return new OutputStreamWriter(out, "UTF-8");
    }
    catch (UnsupportedEncodingException ex) {
      throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec
    }
  }
376561
public static void process(InputStream inputStream, StreamHandler handler, byte[] buffer) throws IOException {
    LOGGER.trace("process(InputStream, StreamHandler, byte[])");
    LOGGER.debug("buffer size: {} bytes", buffer != null ? buffer.length : "null");
    int read = -1;
    while( (read = inputStream.read(buffer)) != -1 ) {
      LOGGER.debug("{} bytes read from stream", read);
      handler.handleStreamBuffer(buffer, 0, read);
    }
  }
465191
public static byte[] decode(InputStream in) {
        try {
            return IOUtils.toByteArray(decodeToStream(in));
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }
772270
protected String writeInputStreamAsString(InputStream instream) {
    String value = null;
    try {
      value = IOUtils.toString(instream, "UTF-8");
      System.out.println(value);

    } catch(IOException ioe) {
      //Do nothing
    }
    return value;
  }
92760
@Override
    public void doRender(Invocation inv) throws Exception {
        if (StringUtils.isEmpty(text)) {
            return;
        }
        
        if (logger.isDebugEnabled()) {
        	logger.debug("trying to render text:" + text);
        }
        
        HttpServletResponse response = inv.getResponse();
        String oldEncoding = response.getCharacterEncoding();
        if (StringUtils.isBlank(oldEncoding) || oldEncoding.startsWith("ISO-")) {
            String encoding = inv.getRequest().getCharacterEncoding();
            Assert.isTrue(encoding != null);
            response.setCharacterEncoding(encoding);
            if (logger.isDebugEnabled()) {
                logger.debug("set response.characterEncoding by default:"
                        + response.getCharacterEncoding());
            }
        }
        
        if (response.getContentType() == null) {
            response.setContentType("text/html");
            if (logger.isDebugEnabled()) {
                logger.debug("set response content-type by default: "
                        + response.getContentType());
            }
        }
        sendResponse(response, text);
    }
1286239
private static int readLEInt(InputStream in) throws IOException {
		int i = in.read() & 0xFF;
		i |= (in.read() & 0xFF) << 8;
		i |= (in.read() & 0xFF) << 16;
		i |= (in.read() & 0xFF) << 24;
		return i;
	}
1080368
@Override
  public void readData(BufferedReader in) throws IOException {
    final String LEFT = "left";
    int lineNum = 1;
    // all lines have one rule per line
    boolean doingStop = false;

    for (String line = in.readLine(); line != null && line.length() > 0; line = in.readLine()) {
      try {
        if (line.equals("BEGIN_STOP")) {
          doingStop = true;
          continue;
        }
        String[] fields = StringUtils.splitOnCharWithQuoting(line, ' ', '\"', '\\'); // split on spaces, quote with doublequote, and escape with backslash
        //        System.out.println("fields:\n" + fields[0] + "\n" + fields[1] + "\n" + fields[2] + "\n" + fields[3] + "\n" + fields[4] + "\n" + fields[5]);

        
        short distance = (short)Integer.parseInt(fields[4]);
        IntTaggedWord tempHead = new IntTaggedWord(fields[0], '/', wordIndex, tagIndex);
        IntTaggedWord tempArg = new IntTaggedWord(fields[2], '/', wordIndex, tagIndex);
        IntDependency tempDependency = new IntDependency(tempHead, tempArg, fields[3].equals(LEFT), distance);

        double count = Double.parseDouble(fields[5]);
        if (doingStop) {
          expandStop(tempDependency, distance, count, false);
        } else {
          expandArg(tempDependency, distance, count);
        }
      } catch (Exception e) {
        IOException ioe = new IOException("Error on line " + lineNum + ": " + line);
        ioe.initCause(e);
        throw ioe;
      }
      //      System.out.println("read line " + lineNum + ": " + line);
      lineNum++;
    }
  }
572112
public static boolean isXls(InputStream in) {
		final PushbackInputStream pin = IoUtil.toPushbackStream(in, 8);
		try {
			return FileMagic.valueOf(pin) == FileMagic.OLE2;
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
1063063
private void init(InputStream in) throws java.io.IOException {
        if (in.available() > 2000000) {
        	throw new IOException("Font too big");
        }
        this.file = IOUtils.toByteArray(in);
        this.fsize = this.file.length;
        if (fsize > 2000000) {
        	throw new IOException("Font too big");
        }
        this.current = 0;
    }
1059432
public static Reader getInputStreamReader(InputStream in, String charset) {
    try {
      return new InputStreamReader(in, charset);
    }
    catch (UnsupportedEncodingException ex) {
      throw new RuntimeException(ex); // shouldn't happen since UTF-8 is supported by all JVMs per spec
    }
  }