{"id":88,"date":"2023-02-14T21:41:01","date_gmt":"2023-02-14T13:41:01","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=88"},"modified":"2023-02-14T21:41:29","modified_gmt":"2023-02-14T13:41:29","slug":"java-io-conversion","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/02\/14\/java-io-conversion\/","title":{"rendered":"Java IO\u76f8\u4e92\u8f6c\u6362"},"content":{"rendered":"<h2>byte[]\u548cInputStream\u7684\u76f8\u4e92\u8f6c\u6362<\/h2>\n<h3>byte[]\u8f6c\u6362\u4e3aInputStream<\/h3>\n<pre><code class=\"language-java\">public static final InputStream bytes2InStream(byte[] buf) {\n    return new ByteArrayInputStream(buf);\n}<\/code><\/pre>\n<h3>InputStream\u8f6c\u6362\u4e3abyte[]<\/h3>\n<pre><code class=\"language-java\">public static final byte[] inStream2bytes(InputStream inStream) throws IOException {\n    ByteArrayOutputStream baos = new ByteArrayOutputStream();\n    byte[] buff = new byte[1024];\n    int len = 0;\n    while ((len = inStream.read(buff)) &gt; 0) {\n        baos.write(buff, 0, len);\n    }\n    byte[] bytes = baos.toByteArray();\n    return bytes;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>byte[]\u548cInputStream\u7684\u76f8\u4e92\u8f6c\u6362 byte[]\u8f6c\u6362\u4e3aInputStream public sta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-java-basic"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}