Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Java IO相互转换

byte[]和InputStream的相互转换

byte[]转换为InputStream

public static final InputStream bytes2InStream(byte[] buf) {
    return new ByteArrayInputStream(buf);
}

InputStream转换为byte[]

public static final byte[] inStream2bytes(InputStream inStream) throws IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] buff = new byte[1024];
    int len = 0;
    while ((len = inStream.read(buff)) > 0) {
        baos.write(buff, 0, len);
    }
    byte[] bytes = baos.toByteArray();
    return bytes;
}
上一篇 国际化:Java平台下的Locale类
下一篇 LocalDateTime的增加和减少