import java.io.*;
class ByteArrayInputStreamDemo{
public static void main(String[] args)
{
String strTmp = "ShengJiahui";
byte b[] = strTmp.getBytes();
ByteArrayInputStream in = new ByteArrayInputStream(b);
for(int i=0;i<2;i++){
int c;
while((c=in.read())!=-1){
if(i==0){
System.out.print((char)c);
}else{
System.out.print(Character.toUpperCase((char)c));
}
}
System.out.println();
in.reset();
}
}
}
本文通过一个具体示例展示了如何使用 Java 的 ByteArrayInputStream 类来读取字节数组中的数据,并且演示了如何将读取到的数据转换为大写形式进行输出。
658

被折叠的 条评论
为什么被折叠?



