{"id":98345,"date":"2020-03-24T18:41:21","date_gmt":"2020-03-24T10:41:21","guid":{"rendered":"http:\/\/4563.org\/?p=98345"},"modified":"2020-03-24T18:41:21","modified_gmt":"2020-03-24T10:41:21","slug":"%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%8b-java-%e9%87%8c%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%bc%96%e7%a0%81%e9%97%ae%e9%a2%98%e3%80%82%e3%80%82%e3%80%82%e8%80%81%e7%94%9f%e5%b8%b8%e8%b0%88%e4%ba%86","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=98345","title":{"rendered":"\u8bf7\u6559\u4e00\u4e0b Java \u91cc\u7684\u5b57\u7b26\u4e32\u7f16\u7801\u95ee\u9898\u3002\u3002\u3002\u8001\u751f\u5e38\u8c08\u4e86"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u4e00\u4e0b Java \u91cc\u7684\u5b57\u7b26\u4e32\u7f16\u7801\u95ee\u9898\u3002\u3002\u3002\u8001\u751f\u5e38\u8c08\u4e86               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <span><i><\/i> 56<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u5047\u8bbe\u6709\u4e00\u4e2a java \u9879\u76ee\uff0c\u5b83\u7684\u6240\u6709\u6587\u4ef6\u90fd\u6309 GBK \u7f16\u7801\u4fdd\u5b58\u3002<\/p>\n<p>\u6709\u8fd9\u6837\u4e00\u884c\u4ee3\u7801<\/p>\n<p>String s = &#8220;\u4e2d\u6587&#8221;\uff1b<\/p>\n<p>\u90a3\u4e48\u5f53\u7a0b\u5e8f\u8fd0\u884c\u8d77\u6765\u540e\uff0cJVM \u4e2d\uff0cs \u7684\u7f16\u7801\u662f\u4ec0\u4e48\u6837\u7684\uff1f\uff08\u5bf9\u7f51\u4e0a\u8bf4\u7684\u73af\u5883\u9ed8\u8ba4\u7684\u7f16\u7801\u4e0d\u592a\u7406\u89e3\uff0c\u8fd9\u91cc\u7684\u73af\u5883\u662f\u6307\u4ec0\u4e48\uff1f JVM \uff1f windows10 \uff1f\uff09<\/p>\n<p>\u7136\u540e\u5982\u679c\u6211\u4eec\u5728\u8fd9\u4e2a\u9879\u76ee\u91cc\u52a0\u4e00\u4e9b\u6700\u7b80\u5355\u7684 socket \u76f8\u5173\u7684\u4ee3\u7801\uff0c\u6bd4\u5982\u83b7\u5f97 socket \u7684\u8f93\u51fa\u6d41\uff0c\u5c06 s \u8f93\u51fa\u3002\u90a3\u4e48\u5728\u8f93\u51fa\u6d41\u91cc\uff0cs \u7684\u7f16\u7801\u662f\u4ec0\u4e48\u6837\u7684\uff1f<\/p>\n<p>\u8c22\u8c22\u6307\u70b9\uff01      <\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"708926\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gy123 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             jdk \u73af\u5883\u4f1a\u9ed8\u8ba4\u6839\u636e\u7cfb\u7edf\u73af\u5883\u8bbe\u7f6e\u7f16\u7801,\u5e76\u4e14\u53ef\u4ee5\u4fee\u6539,\u6240\u4ee5\u7f16\u7a0b\u4e2d\u4f7f\u7528 charset.default \u5c31\u662f\u8ddf\u968f\u7cfb\u7edf,\u6216\u8005\u6307\u5b9a\u7279\u5b9a\u7f16\u7801\u65b9\u5f0f;\u8bf4\u9519\u8bf7\u6307\u6b63                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708927\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lhx2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             JVM \u91cc\u9762\u90fd\u662f char \u6570\u7ec4\uff0cUTF-16 \u7684\uff0c\u548c GBK UTF-8 \u65e0\u5173                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708928\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lhx2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8f6c\u6d41\u7684\u8bdd\uff0c\u770b API \u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708929\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @gy123 <br \/>@lhx2008 <br \/>\u989d\u3002\u3002\u6211\u600e\u4e48\u611f\u89c9\u4f60\u4eec\u4e24\u8bf4\u7684\u6709\u51b2\u7a81\u3002\u3002\u3002\u3002charset.default \u4e00\u822c\u5c31\u662f utf-16 \uff1f<br \/>\u53e6\u5916 java \u4ee3\u7801\u6240\u5728\u7684\u6587\u4ef6\u7528\u4ec0\u4e48\u7f16\u7801\u683c\u5f0f\u4fdd\u5b58\u4e0e\u5b9e\u9645\u8fd0\u884c\u65f6 JVM \u4e2d\u7684\u5b57\u7b26\u4e32\u7f16\u7801\u5b8c\u5168\u6ca1\u5173\u7cfb\u4e48\uff1f<\/p>\n<p>@lhx2008 <br \/>\u8f6c\u6d41\u7684\u8bdd\u770b API \u80fd\u5177\u4f53\u8bf4\u8bf4\u4e48\uff0c\u5c31\u6bd4\u5982\u6211\u5c31\u5f88\u5355\u7eaf\u5730\u8c03\u7528 write \u65b9\u6cd5\uff0c\u4e0d\u4f20\u4efb\u4f55\u7f16\u7801\u683c\u5f0f\u7684\u8981\u6c42\u7684\u53c2\u6570\uff0c\u4f1a\u5982\u4f55\u5462\uff1f<\/p>\n<p>\u8c22\u8c22                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708930\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Newyorkcity <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u518d\u8865\u5145\u4e00\u4e2a\u95ee\u9898<\/p>\n<p>\u5c31\u4e0a\u8ff0\u5047\u8bbe\u7684\u9879\u76ee\uff0c\u91cc\u9762\u6240\u6709\u6587\u4ef6\u90fd\u662f\u7528 GBK \u7f16\u7801\u4fdd\u5b58\u7684\u561b\uff0c\u90a3\u5047\u8bbe\u64cd\u4f5c\u7cfb\u7edf\u7684\u9ed8\u8ba4\u7f16\u7801\uff08\u8fd9\u4e2a\u5c31\u662f\u7f51\u4e0a\u8bf4\u7684\u9ed8\u8ba4\u7f16\u7801\uff1f\uff09\u662f UTF8\uff0c\u90a3\u4e48 String s = &#8220;\u4e2d\u6587\u201c\uff0c\u7a0b\u5e8f\u8fd0\u884c\u8d77\u6765\u540e\uff0c\u80fd\u591f\u6b63\u786e\u7684\u7406\u89e3 s \u8981\u88ab\u8d4b\u7684\u503c\u4e48\uff1f                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708931\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lhx2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Newyorkcity #4 charset.default \u4e00\u822c\u662f UTF-8 \u6216\u8005 GBK\uff0csocket \u7684\u662f\u5b57\u8282\u6d41\uff0c\u4f60\u5982\u679c\u7528 new PrintWriter \u8f6c\u6362 string \u5230\u5b57\u8282\u6d41\uff0c\u8fd9\u91cc\u9700\u8981 decode\uff0c\u5982\u679c\u4f60\u4e0d\u6307\u5b9a\u53c2\u6570\uff0c\u7f16\u7801\u7528 charset.default                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708932\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lhx2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Newyorkcity #5 java \u547d\u4ee4\u6709\u53c2\u6570 -Dfile.encoding=GBK\uff0c\u5982\u679c java \u547d\u4ee4\u4e0d\u8ba4\u8bc6\u4f60\u6587\u4ef6\u7684\u7f16\u7801\uff0c\u4e2d\u6587\u4f1a\u4e71\u7801\u3002\u81f3\u4e8e\u4f1a\u4e0d\u4f1a\u81ea\u52a8\u8bc6\u522b\uff0c\u6211\u6ca1\u8bd5\u8fc7                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708933\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lhx2008 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lhx2008 #6 decode -&gt; encode \u6253\u9519\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708934\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : guyeu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6e90\u4ee3\u7801\u7684\u7f16\u7801\u548c\u8fd0\u884c\u671f\u7684\u5185\u5b58\u6beb\u65e0\u5173\u7cfb\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"708935\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : maokabc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7f16\u8bd1\u540e\u5728 class \u6587\u4ef6\u5e38\u91cf\u6c60\u4e2d\u662f modified utf-8\uff0c\u8fd0\u884c\u65f6 String\u3001char \u662f utf16\uff0c\u4ee3\u7406\u5bf9\u9700\u8981\u4f7f\u7528 2 \u4e2a char \u8868\u793a\u4e00\u4e2a\u7801\u70b9\u3002\u5199\u5165\u6d41\u4e00\u822c\u5305\u88c5 DataOutputStream \u7528 wirteUTF \u65b9\u6cd5\uff0c\u8bfb\u53d6\u7528 DataInputStream \u7684 readUTF\uff0c\u683c\u5f0f\u548c class \u6587\u4ef6\u91cc utf8 \u5e38\u91cf\u4e00\u6837\u3002\u6e90\u6587\u4ef6\u7f16\u7801\u53ea\u80fd\u5f71\u54cd\u5230 javac                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u4e00\u4e0b Java \u91cc\u7684\u5b57\u7b26\u4e32\u7f16\u7801&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/98345"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98345"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/98345\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98345"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}