{"id":3875,"date":"2019-02-15T18:13:28","date_gmt":"2019-02-15T10:13:28","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=3875"},"modified":"2019-02-15T18:13:28","modified_gmt":"2019-02-15T10:13:28","slug":"%e6%b5%85%e8%b0%88-java-%e4%b8%ad%e7%9a%84%e5%ad%97%e8%8a%82%e6%b5%81%e4%b8%8e%e5%ad%97%e7%ac%a6%e6%b5%81","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=3875","title":{"rendered":"\u6d45\u8c08 Java \u4e2d\u7684\u5b57\u8282\u6d41\u4e0e\u5b57\u7b26\u6d41"},"content":{"rendered":"<p>\n\t\u6700\u8fd1\uff0c\u6211\u5199\u7684\u90fd\u662f\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\u3002\u4e00\u4e9b\u4eba\u4e0d\u5c51\u4e8e\u770b\uff0c\u770b\u4e86\u6807\u9898\u5c31\u79c1\u4fe1\u6211&ldquo;\u80fd\u4e0d\u80fd\u5199\u70b9\u9ad8\u7ea7\u7684\uff0c\u770b\u4e86\u8fd9\u6807\u9898\u6211\u5c31\u77e5\u9053\u5185\u5bb9\u4e86\uff0c\u5728\u8fd9\u6837\u6211\u5c31\u53d6\u5173\u4e86\uff01&rdquo;\n<\/p>\n<p>\n\t\u4f46\u662f\u4e5f\u6709\u4eba\u8868\u793a\u559c\u6b22\u770b\u3002&ldquo;\u5185\u5bb9\u867d\u7136\u57fa\u7840\uff0c\u4f46\u662f\u770b\u5b8c\u540e\u6211\u6709\u4e86\u65b0\u7684\u8ba4\u77e5\uff01&rdquo;\n<\/p>\n<p>\n\t\u6240\u4ee5\uff0c\u6211\u7684\u5c34\u5c2c\u7684\u53d6\u5173\u6570\u636e\u662f\u65f6\u5019\u7ed9\u5927\u5bb6\u5c55\u793a\u4e00\u4e0b\u4e86\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u516c\u4f17\u53f7\u53d6\u5173\u6570\u636e\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g079opm028j20q206st9h.jpg\" style=\"width: 938px;height: 244px\" \/>\n<\/p>\n<p>\n\t\u6700\u8fd1 30 \u5929\u7684\u8d8b\u52bf\u56fe\u5982\u4e0b\u6240\u793a\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"\u516c\u4f17\u53f7\u6700\u8fd1 30 \u5929\u7684\u8d8b\u52bf\u56fe\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g079pmyphdj20nt0cd75f.jpg\" style=\"width: 857px;height: 445px\" \/>\n<\/p>\n<p>\n\t\u6211\u8981\u611f\u8c22\u4e00\u90e8\u5206\u7f51\u53cb\u901a\u8fc7\u8f6c\u53d1\u3001\u8bc4\u8bba\u7b49\u5f62\u5f0f\u5bf9\u6211\u7684\u652f\u6301\uff01\u8c22\u8c22\u4f60\u4eec\uff01\n<\/p>\n<hr \/>\n<p>\n\t\u597d\u4e86\uff0c\u4e0b\u9762\u6211\u4eec\u5f00\u59cb\u4eca\u5929\u7684\u5185\u5bb9\u3002\n<\/p>\n<p>\n\t\u5b57\u8282\u6d41\u548c\u5b57\u7b26\u6d41\u5176\u5b9e\u5f88\u597d\u7406\u89e3\uff01\n<\/p>\n<p>\n\t\u5b57\u8282\u6d41\u5c31\u662f Byte \u6d41\uff0c\u5b57\u8282\u5c31\u662f Byte\u3002\n<\/p>\n<p>\n\t\u5b57\u7b26\u6d41\u5c31\u662f Character \u6d41\uff0c\u5b57\u7b26\u5c31\u662f Character\u3002\n<\/p>\n<p>\n\t\u8fd9\u91cc\u9762\u6709\u4e24\u4e2a\u5355\u4f4d\u6362\u7b97\u5927\u5bb6\u9700\u8981\u8bb0\u4f4f\u4e00\u4e0b\u3002\n<\/p>\n<ul>\n<li>\n\t\t1 byte = 8 bit\n\t<\/li>\n<li>\n\t\t1 char = 2 byte = 16 bit\n\t<\/li>\n<\/ul>\n<p>\n\t\u867d\u7136 1 bit \u624d\u662f\u6570\u636e\u771f\u6b63\u7684\u6700\u5c0f\u5355\u4f4d\uff0c\u4f46 1 bit \u7684\u4fe1\u606f\u91cf\u592a\u5c11\u4e86\u3002\u8981\u8868\u793a\u4e00\u4e2a\u6709\u7528\u7684\u4fe1\u606f\uff0c\u9700\u8981\u597d\u51e0\u4e2a bit \u4e00\u8d77\u8868\u793a\u3002\u6240\u4ee5\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u5b57\u8282\u662f\u6570\u636e\u6700\u5c0f\u7684\u57fa\u672c\u5355\u4f4d\u3002\n<\/p>\n<p>\n\t\u6bd4\u5982\uff0c\u6211\u4eec\u719f\u77e5\u7684\u57fa\u672c\u578b\u7684\u5927\u5c0f\u90fd\u662f 8 bit\uff08\u4e5f\u5c31\u662f1\u5b57\u8282\uff09\u7684\u6574\u6570\u500d\uff1a\n<\/p>\n<ul>\n<li>\n\t\tboolean: 1 byte\n\t<\/li>\n<li>\n\t\tshort: 2 byte\n\t<\/li>\n<li>\n\t\tint: 4 byte\n\t<\/li>\n<li>\n\t\tfloat: 4 byte\n\t<\/li>\n<li>\n\t\tlong: 8 byte\n\t<\/li>\n<li>\n\t\tdouble: 8 byte\n\t<\/li>\n<\/ul>\n<p>\n\t\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u8ba4\u8bc6\u7684\u90fd\u662f\u5b57\u8282\u3002\u4f46\u662f\uff0cJava I\/O \u7684\u7f16\u7801\u7cfb\u7edf\u63d0\u4f9b\u7684 Java IO \u5e93\u6709\u4e24\u4e2a\u652f\u7cfb\uff0c\u9762\u5411\u5b57\u8282\u6d41\u7684 InputStream \u548c OutputStream\uff1b\u9762\u5411\u5b57\u7b26\u7684 Reader \u548c Writer\u3002\n<\/p>\n<p>\n\t\u4e3a\u4ec0\u4e48\u8981\u6709\u5b57\u7b26\u6d41\u5462\uff1f\u90a3\u662f\u56e0\u4e3a\u82f1\u6587\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u5b57\u8282\u6765\u8868\u793a\uff0c\u4f46\u662f\u4e2d\u6587\u3001\u65e5\u6587\u3001\u97e9\u6587\u7b49\u6ca1\u6cd5\u7528\u5b57\u8282\u6765\u8868\u793a\u4e86\uff0c\u6240\u6709\u4eba\u4eec\u5c31\u60f3\u5230\u4e86\u65b0\u7684\u5b57\u7b26\u7f16\u7801\u96c6\u3002\u6bd4\u5982\uff0cUnicode \u5b57\u7b26\u96c6\uff0cGB 18030\uff0cGBK\uff0cBig5\uff0cISO-8859-1 \u7b49\u3002\n<\/p>\n<p>\n\t\u6240\u4ee5\uff0c\u6700\u7ec8\u5c31\u662f\u4e00\u4e2a\u5b57\u7b26\u7528 1 \u4e2a\u30012 \u4e2a\u6216 4 \u4e2a\u5b57\u8282\u7ec4\u6210\u3002\u603b\u800c\u8a00\u4e4b\uff0c\u4e00\u5207\u90fd\u662f\u5b57\u8282\u6d41\uff0c\u5176\u5b9e\u6ca1\u6709\u5b57\u7b26\u6d41\u8fd9\u4e2a\u4e1c\u897f\u3002\u5b57\u7b26\u53ea\u662f\u6839\u636e\u7f16\u7801\u96c6\u5bf9\u5b57\u8282\u6d41\u7ffb\u8bd1\u4e4b\u540e\u7684\u4ea7\u7269\u3002\n<\/p>\n<p>\n\t\u6240\u4ee5\uff0c\u5b57\u8282\u6d41\u7684 InputStream \u548c OutputStream \u624d\u662f\u4e00\u5207\u7684\u57fa\u7840\u3002\u5b9e\u9645\u603b\u7ebf\u4e2d\u6d41\u52a8\u7684\u53ea\u6709\u5b57\u8282\u6d41\u3002\u9700\u8981\u5bf9\u5b57\u8282\u6d41\u505a\u7279\u6b8a\u89e3\u7801\u624d\u80fd\u5f97\u5230\u5b57\u7b26\u6d41\u3002Java \u4e2d\u8d1f\u8d23\u4ece\u5b57\u8282\u6d41\u5411\u5b57\u7b26\u6d41\u89e3\u7801\u7684\u6865\u6881\u662fInputStreamReader \u548c InputStreamWriter\u3002\n<\/p>\n<p>\n\t\u770b\u4e0b\u9762\u7684 InputStreamReader \u548c OutputStreamWriter \u7684\u7ed3\u6784\u56fe\u3002\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"Java \u4e2d\u5b57\u8282\u6d41\u4e0e\u5b57\u7b26\u6d41\u7684\u533a\u522b?\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/wx1.sinaimg.cn\/large\/8fa5dcfcgy1g079u96zoqj20b10camxy.jpg\" style=\"width: 397px;height: 442px\" \/>\n<\/p>\n<p>\n\t\u5b9e\u9645\u8d1f\u8d23\u7f16\u7801\u548c\u89e3\u7801\u7684\u662f StreamDecoder \u7c7b\u548c StreamEncoder \u7c7b\u3002\u7f16\u7801\u8fc7\u7a0b\u4e2d\u5fc5\u987b\u6307\u5b9a\u4f7f\u7528\u7684\u5b57\u7b26\u7f16\u7801\u96c6 Charset\u3002\u6240\u4ee5 InputStreamReader \u548c OutputStreamWriter \u7684\u6784\u9020\u5668\u90fd\u5e26\u6709 Charset \u7c7b\u578b\u7684\u53c2\u6570\u3002\n<\/p>\n<p>\n\t\u5982\u679c\u6ca1\u6709\u6307\u5b9a\u7f16\u7801\u96c6\uff0c\u5c06\u4f7f\u7528\u7cfb\u7edf\u9ed8\u8ba4\u7f16\u7801\u96c6\u3002\u800c\u6211\u4eec\u7ecf\u5e38\u4f7f\u7528\u7684 FileInputReader \u548c FileOutputWriter \u5c31\u662f InputStreamReader \u548c OutputStreamWriter \u7684\u6d3e\u751f\u7c7b\u3002\n<\/p>\n<p>\n\t\u5230\u73b0\u5728\uff0c\u4f60\u662f\u4e0d\u662f\u60f3\u8d77\u4e86\u90a3\u53e5\u8bdd\u3002&ldquo;\u4e16\u754c\u4e0a\u672c\u6765\u6ca1\u6709\u8def\uff0c\u8d70\u7684\u4eba\u591a\u4e86\uff0c\u4e5f\u5c31\u53d8\u6210\u4e86\u8def\u3002&rdquo;\n<\/p>\n<p>\n\t\u8ba1\u7b97\u673a\u4e2d\u672c\u6ca1\u6709\u5b57\u7b26\u6d41\uff0c\u4e00\u5f00\u59cb\u53ea\u9002\u7528\u4e8e\u82f1\u6587\uff0c\u4f46\u662f\u4e92\u8054\u7f51\u5c5e\u4e8e\u5168\u4eba\u7c7b\u7684\uff0c\u6240\u4ee5\u4eba\u4eec\u53c8\u641e\u51fa\u4e86\u5b57\u7b26\u6d41\u3002\u5b57\u7b26\u53ea\u662f\u5305\u88c5\u7684\u5b57\u8282\u800c\u5df2\u3002<\/p>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=3875\">\u6d45\u8c08 Java \u4e2d\u7684\u5b57\u8282\u6d41\u4e0e\u5b57\u7b26\u6d41<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\uff0c\u6211\u5199\u7684\u90fd\u662f\u4e00\u4e9b\u57fa\u7840\u77e5\u8bc6\u3002\u4e00\u4e9b\u4eba\u4e0d\u5c51\u4e8e\u770b\uff0c\u770b\u4e86\u6807\u9898\u5c31\u79c1\u4fe1\u6211&ldquo;\u80fd\u4e0d\u80fd\u5199\u70b9\u9ad8\u7ea7\u7684\uff0c\u770b\u4e86\u8fd9\u6807\u9898\u6211\u5c31\u77e5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1170,71,1793,409,1115],"class_list":["post-3875","post","type-post","status-publish","format-standard","hentry","category-java","tag-inputstream","tag-outputstream","tag-tokenstream","tag-409","tag-1115"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3875","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3875"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3875\/revisions"}],"predecessor-version":[{"id":3876,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3875\/revisions\/3876"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}