use of org.apache.jena.atlas.io.InputStreamBuffered in project jena by apache.
the class TestInputStreamBuffered method test_01.
@Test
public void test_01() throws IOException {
InputStream in = stream("");
InputStream in2 = new InputStreamBuffered(in);
int x = count(in2);
assertEquals(0, x);
}
use of org.apache.jena.atlas.io.InputStreamBuffered in project jena by apache.
the class TestInputStreamBuffered method test_02.
@Test
public void test_02() throws IOException {
InputStream in = stream(1, 2, 3, 4);
InputStream in2 = new InputStreamBuffered(in);
check(in2, 1, 2, 3, 4);
}
use of org.apache.jena.atlas.io.InputStreamBuffered in project jena by apache.
the class TestInputStreamBuffered method test_03.
@Test
public void test_03() throws IOException {
InputStream in = stream(1, 2, 3, 4);
InputStream in2 = new InputStreamBuffered(in, 2);
check(in2, 1, 2, 3, 4);
}
use of org.apache.jena.atlas.io.InputStreamBuffered in project jena by apache.
the class utf8 method main.
/** Simple program to help hunt down bad UTF-8 encoded characters */
public static void main(String[] args) {
long INIT_LINE = 1;
long INIT_COL = 1;
if (args.length == 0)
args = new String[] { "-" };
String label = "";
for (String fn : args) {
if (args.length > 1)
label = fn + ": ";
InputStream in = IO.openFile(fn);
in = new InputStreamBuffered(in);
long charCount = 0;
long lineNum = INIT_LINE;
long colNum = INIT_COL;
InStreamUTF8 utf8 = null;
try {
utf8 = new InStreamUTF8(in);
for (; ; ) {
int ch = utf8.read();
if (ch == -1)
break;
charCount++;
if (ch == '\n') {
lineNum++;
colNum = INIT_COL;
} else
colNum++;
if (!Character.isDefined(ch))
throw new AtlasException(String.format("No such codepoint: 0x%04X", ch));
}
System.out.printf("%s: chars = %d , lines = %d\n", fn, charCount, lineNum);
} catch (AtlasException ex) {
System.out.printf(label + "[line=%d, col=%d] %s\n", lineNum, colNum, ex.getMessage());
} finally {
IO.close(utf8);
}
}
}
use of org.apache.jena.atlas.io.InputStreamBuffered in project jena by apache.
the class TestInputStreamBuffered method test_04.
@Test
public void test_04() throws IOException {
InputStream in = stream(1, 2, 3, 4);
InputStream in2 = new InputStreamBuffered(in, 1);
check(in2, 1, 2, 3, 4);
assertEquals(-1, in.read());
}
Aggregations