/** * Returns a {@code CharSource} for the same bytes, converted to UTF-8 using a Byte-Order Mark if available. * * @return the equivalent {@code CharSource} */ public CharSource asCharSourceUtf8UsingBom() { return CharSource.wrap(readUtf8UsingBom()); }
public void test_methods() throws IOException { ArrayByteSource test = ArrayByteSource.copyOf(new byte[] {65, 66, 67}); assertEquals(test.size(), 3); assertEquals(test.isEmpty(), false); assertEquals(test.sizeIfKnown().isPresent(), true); assertEquals(test.sizeIfKnown().get(), (Long) 3L); assertEquals(test.readUtf8(), "ABC"); assertEquals(test.readUtf8UsingBom(), "ABC"); assertEquals(test.asCharSourceUtf8UsingBom().read(), "ABC"); assertEquals(test.toString(), "ArrayByteSource[3 bytes]"); }