📄 testbytearrayinputstream.java
字号:
package apibook.c3.s7;import java.io.*;//测试ByteArrayInputStream类public class TestByteArrayInputStream { public TestByteArrayInputStream() { } public static void main(String[] args) { byte[] inputbytes = { 'a', 'b', 'c', 'd', 'e'};//字节数组 ByteArrayInputStream in = new ByteArrayInputStream(inputbytes); System.out.println("Available: " + in.available());//输出可用字节数 int b; while ((b=in.read()) >= 0) //读取"abcde" System.out.print((char)b); in.reset();//重设流位置 System.out.println(); in.skip(3); //跳过3个字节"abc" while ((b=in.read()) >= 0) //读字节数据"de" System.out.print((char)b); System.out.println(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -