public static String asStringAlways(InputStream in) { if (in == null) { return StringUtils.EMPTY; } try { return asBytes(in).toString(); } catch (IOException ex) { return StringUtils.EMPTY; } }
public static String asString(InputStream in) throws IOException { return asBytes(in).toString(); }
public static BytesArray asBytes(InputStream in) throws IOException { BytesArray ba = unwrapStreamBuffer(in); if (ba != null) { return ba; } return asBytes(new BytesArray(in.available()), in); }
public Scroll read(InputStream content) throws IOException { Assert.notNull(content); //copy content BytesArray copy = IOUtils.asBytes(content); content = new FastByteArrayInputStream(copy); if (log.isTraceEnabled()) { log.trace("About to parse scroll content " + copy); } Parser parser = new JacksonJsonParser(content); try { return read(parser, copy); } finally { parser.close(); } }
@Test public void testStreamSize() throws Exception { BytesArray input = IOUtils.asBytes(getClass().getResourceAsStream("escape-size.txt")); assertEquals(5 * 2, input.size); }
@Before public void before() throws Exception { InputStream in = new FastByteArrayInputStream(IOUtils.asBytes(getClass().getResourceAsStream("parser-test-nested.json"))); parser = new JacksonJsonParser(in); }
public void testByteToCharFromFile() throws Exception { BytesArray input = IOUtils.asBytes(getClass().getResourceAsStream("/org/elasticsearch/hadoop/serialization/scrollReaderTestData/matched-queries/scroll.json")); int[] chars = new int[] { 555, 558, 1008, 1009, 1649 }; int[] bytePositions = BytesUtils.charToBytePosition(input, chars); assertEquals(570, bytePositions[0]); assertEquals(575, bytePositions[1]); assertEquals(1071, bytePositions[2]); assertEquals(1072, bytePositions[3]); //assertEquals(1640, bytePositions[1]); } }
@Test public void testByteToChar() throws Exception { BytesArray input = IOUtils.asBytes(getClass().getResourceAsStream("escaped-chars.txt")); int[] chars = new int[] { 9, 14, 0 }; int[] bytePositions = BytesUtils.charToBytePosition(input, chars); assertEquals(10, bytePositions[0]); // LF/CR assertEquals((TestUtils.isWindows() ? 19 : 20), bytePositions[1]); assertEquals(0, bytePositions[2]); }
public static String asStringAlways(InputStream in) { if (in == null) { return StringUtils.EMPTY; } try { return asBytes(in).toString(); } catch (IOException ex) { return StringUtils.EMPTY; } }
public static String asStringAlways(InputStream in) { if (in == null) { return StringUtils.EMPTY; } try { return asBytes(in).toString(); } catch (IOException ex) { return StringUtils.EMPTY; } }
public static String asStringAlways(InputStream in) { if (in == null) { return StringUtils.EMPTY; } try { return asBytes(in).toString(); } catch (IOException ex) { return StringUtils.EMPTY; } }
public static String asStringAlways(InputStream in) { if (in == null) { return StringUtils.EMPTY; } try { return asBytes(in).toString(); } catch (IOException ex) { return StringUtils.EMPTY; } }
public static String asString(InputStream in) throws IOException { return asBytes(in).toString(); }
public static String asString(InputStream in) throws IOException { return asBytes(in).toString(); }
public static String asString(InputStream in) throws IOException { return asBytes(in).toString(); }
public static String asString(InputStream in) throws IOException { return asBytes(in).toString(); }
public static BytesArray asBytes(InputStream in) throws IOException { BytesArray ba = unwrapStreamBuffer(in); if (ba != null) { return ba; } return asBytes(new BytesArray(in.available()), in); }
public static BytesArray asBytes(InputStream in) throws IOException { BytesArray ba = unwrapStreamBuffer(in); if (ba != null) { return ba; } return asBytes(new BytesArray(in.available()), in); }
public static BytesArray asBytes(InputStream in) throws IOException { BytesArray ba = unwrapStreamBuffer(in); if (ba != null) { return ba; } return asBytes(new BytesArray(in.available()), in); }
public static BytesArray asBytes(InputStream in) throws IOException { BytesArray ba = unwrapStreamBuffer(in); if (ba != null) { return ba; } return asBytes(new BytesArray(in.available()), in); }