其他
Java教程-Java ByteArrayInputStream类
Java ByteArrayInputStream类声明
public class ByteArrayInputStream extends InputStream
专属福利
Java ByteArrayInputStream类的构造方法
Java ByteArrayInputStream类的方法
package com.javatpoint;
import java.io.*;
public class ReadExample {
public static void main(String[] args) throws IOException {
byte[] buf = { 35, 36, 37, 38 };
//创建新的字节数组输入流
ByteArrayInputStream byt = new ByteArrayInputStream(buf);
int k = 0;
while ((k = byt.read()) != -1) {
//将字节转换为字符
char ch = (char) k;
System.out.println("ASCII value of Character is:" + k + "; Special character is: " + ch);
}
}
}
ASCII value of Character is:35; Special character is: #
ASCII value of Character is:36; Special character is: $
ASCII value of Character is:37; Special character is: %
ASCII value of Character is:38; Special character is: &
我就知道你会点赞+“在看”