【发布时间】:2016-01-22 03:31:50
【问题描述】:
这是我的文件 C://test.txt 组成 ACBDE FGHIJ
我想从 F 一直读到 J。 所以输出是FGHIJ。我将如何在使用偏移量读取的 InputStream 中做到这一点。 这是我的部分实现。
InputStream is = null;
byte[] buffer = null;
char c;
try {
is = new FileInputStream("D://test.txt");
buffer = new byte[is.available()];
System.out.println("Characters printed:");
is.read(buffer, 5, 5);
for (byte b : buffer) {
if (b == 0)
// if b is empty
c = '-';
else
c = (char) b;
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
if (is != null)
is.close();
}
请帮我解决我的问题:D
【问题讨论】:
标签: java byte inputstream fileinputstream