{"id":1317,"date":"2022-10-30T22:43:38","date_gmt":"2022-10-30T14:43:38","guid":{"rendered":"https:\/\/qaqaq.top\/?p=1317"},"modified":"2022-11-27T12:39:46","modified_gmt":"2022-11-27T04:39:46","slug":"io%e6%b5%81-%e7%bc%93%e5%86%b2%e6%b5%81%e8%af%be%e5%90%8e%e7%bb%83%e4%b9%a01","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=1317","title":{"rendered":"IO\u6d41-\u7f13\u51b2\u6d41\u8bfe\u540e\u7ec3\u4e601"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>package top.qaqaq.java.P598;\r\n\r\nimport org.junit.jupiter.api.Test;\r\n\r\nimport java.io.FileInputStream;\r\nimport java.io.FileOutputStream;\r\nimport java.io.IOException;\r\n\r\n\/**\r\n * @author RichieZhang\r\n * @create 2022-10-30 \u4e0b\u5348 12:24\r\n *\/\r\npublic class PicTest {\r\n\r\n    \/\/\u56fe\u7247\u7684\u52a0\u5bc6\r\n    @Test\r\n    public void test1() {\r\n\r\n        FileInputStream fis = null;\r\n        FileOutputStream fos = null;\r\n        try {\r\n            fis = new FileInputStream(\"\u7231\u60c5\u4e0e\u53cb\u60c5.jpg\");\r\n            fos = new FileOutputStream(\"\u7231\u60c5\u4e0e\u53cb\u60c5secret.jpg\");\r\n\r\n            byte&#91;] buffer = new byte&#91;20];\r\n            int len;\r\n            while ((len = fis.read(buffer)) != -1){\r\n                \/\/\u5b57\u8282\u6570\u7ec4\u8fdb\u884c\u4fee\u6539\r\n                \/\/\u9519\u8bef\u7684\r\n    \/\/            for (byte b : buffer){\r\n    \/\/                b = (byte) (b ^ 5);\r\n    \/\/            }\r\n                \/\/\u6b63\u786e\u7684\r\n                for (int i = 0; i &lt; len; i ++){\r\n                    buffer&#91;i] = (byte) (buffer&#91;i] ^ 5);\r\n                }\r\n                fos.write(buffer,0,len);\r\n            }\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        } finally {\r\n            if (fos != null){\r\n                try {\r\n                    fos.close();\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                }\r\n            }\r\n\r\n            if (fis != null){\r\n                try {\r\n                    fis.close();\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                }\r\n            }\r\n        }\r\n\r\n    }\r\n\r\n    \/\/\u56fe\u7247\u7684\u89e3\u5bc6\r\n    @Test\r\n    public void test2() {\r\n\r\n        FileInputStream fis = null;\r\n        FileOutputStream fos = null;\r\n        try {\r\n            fis = new FileInputStream(\"\u7231\u60c5\u4e0e\u53cb\u60c5secret.jpg\");\r\n            fos = new FileOutputStream(\"\u7231\u60c5\u4e0e\u53cb\u60c54.jpg\");\r\n\r\n            byte&#91;] buffer = new byte&#91;20];\r\n            int len;\r\n            while ((len = fis.read(buffer)) != -1){\r\n                \/\/\u5b57\u8282\u6570\u7ec4\u8fdb\u884c\u4fee\u6539\r\n                \/\/\u9519\u8bef\u7684\r\n                \/\/            for (byte b : buffer){\r\n                \/\/                b = (byte) (b ^ 5);\r\n                \/\/            }\r\n                \/\/\u6b63\u786e\u7684\r\n                for (int i = 0; i &lt; len; i ++){\r\n                    buffer&#91;i] = (byte) (buffer&#91;i] ^ 5);\r\n                }\r\n                fos.write(buffer,0,len);\r\n            }\r\n        } catch (IOException e) {\r\n            e.printStackTrace();\r\n        } finally {\r\n            if (fos != null){\r\n                try {\r\n                    fos.close();\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                }\r\n            }\r\n\r\n            if (fis != null){\r\n                try {\r\n                    fis.close();\r\n                } catch (IOException e) {\r\n                    e.printStackTrace();\r\n                }\r\n            }\r\n        }\r\n\r\n    }\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[46],"class_list":["post-1317","post","type-post","status-publish","format-standard","hentry","category-java-code","tag-java"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1317"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1317"}],"version-history":[{"count":1,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions"}],"predecessor-version":[{"id":1318,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/1317\/revisions\/1318"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1317"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}