[英]Using printWriter to write to a byte buffer?
我不确定这是否可能。 我尝试做类似的事情
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(byteStream);
pw.write("TEST STRING");
当我尝试做System.out.println(byteStream.toString())
; 它输出一个空字符串。 当我尝试执行System.out.println(byteStream.size())
,它显示0,这意味着在打印编写器写入ByteArrayOutputStream之后,字节缓冲区为空吗? 我不确定这是否是使用PrintWriter写入字节数组的唯一方法。 还有另一种方法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.