import java.io.*;
public class bytestream{
public static void main(String args[])
{
String str=new String("You can");
byte[] byt=str.getBytes();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
bos.write(byt,0,byt.length);
PrintStream ps=new PrintStream(bos);
ps.println(byt[2]);
}
}
怎么显示
我不用PRINTSTREAM 只用SYSTEM.OUT.PRINTLN就显示了,请问是什么原因
public class bytestream{
public static void main(String args[])
{
String str=new String("You can");
byte[] byt=str.getBytes();
ByteArrayOutputStream bos=new ByteArrayOutputStream();
bos.write(byt,0,byt.length);
PrintStream ps=new PrintStream(bos);
ps.println(byt[2]);
}
}
怎么显示
我不用PRINTSTREAM 只用SYSTEM.OUT.PRINTLN就显示了,请问是什么原因
是表态方法
PrintStream ps=new PrintStream(bos);
ps.println(byt[2]);是将字节写入输出流中,而不是在屏幕上显示.