@Override public void run() { try { in_ = connectInputStream(); LineReader lineReader = new LineReader((InputStream)in_, conf_); while (true) { byte[] b = UTF8ByteArrayUtils.readLine(lineReader); if (b == null) { break; } buf_.append(new String(b, "UTF-8")); buf_.append('\n'); } lineReader.close(); in_.close(); } catch (IOException io) { throw new RuntimeException(io); } }
/** * Read a utf8 encoded line from a data input stream. * @param lineReader LineReader to read the line from. * @return a byte array containing the line * @throws IOException */ public static byte [] readLine(LineReader lineReader) throws IOException { Text out = new Text(); long bytes = lineReader.readLine(out); if (bytes <= 0) return null; return out.getBytes(); }