创建扫描器以获得其中的值。
1
2
3
4
5
6
7
8
9
|
public
static
void
main(String[] args) {
String str =
"HelloWorld"
;
byte
[] bytes = str.getBytes();
System.out.println((
"bytes:"
+
new
String(bytes)));
InputStream bais =
new
ByteArrayInputStream(bytes);
// 我想打印输出bais 中的值,来验证是否正确,请问怎么打印输出啊?
Scanner scanner =
new
Scanner(bais);
System.out.println(
"scanner.next-->"
+scanner.next());
}
|