{"id":39322,"date":"2024-11-26T11:41:12","date_gmt":"2024-11-26T03:41:12","guid":{"rendered":"https:\/\/fwq.ai\/blog\/39322\/"},"modified":"2024-11-26T11:41:12","modified_gmt":"2024-11-26T03:41:12","slug":"%e5%ad%97%e7%ac%a6%e6%80%8e%e4%b9%88%e8%bd%ac%e6%8d%a2%e6%88%90byte%e6%95%b0%e7%bb%84-java","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/39322\/","title":{"rendered":"\u5b57\u7b26\u600e\u4e48\u8f6c\u6362\u6210byte\u6570\u7ec4 java"},"content":{"rendered":"<blockquote><p>\n  \u4f7f\u7528 java \u7f16\u7a0b\u8bed\u8a00\u5c06\u5b57\u7b26\u8f6c\u6362\u6210\u5b57\u8282\u6570\u7ec4\u7684\u65b9\u6cd5\uff1a\u83b7\u53d6\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u3002\u8c03\u7528 getbytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002\u8be5\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u5b57\u8282\u8868\u793a\u7684 byte[] \u6570\u7ec4\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202411\/16\/2024111606275015708.jpg\" class=\"aligncenter\" title=\"\u5b57\u7b26\u600e\u4e48\u8f6c\u6362\u6210byte\u6570\u7ec4 java\u63d2\u56fe\" alt=\"\u5b57\u7b26\u600e\u4e48\u8f6c\u6362\u6210byte\u6570\u7ec4 java\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5c06\u5b57\u7b26\u8f6c\u6362\u6210\u5b57\u8282\u6570\u7ec4\uff1f<\/strong><\/p>\n<p><strong>\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u5bf9\u4e8e Java \u7f16\u7a0b\u8bed\u8a00\uff0c\u4f7f\u7528 getBytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002<\/p>\n<p><strong>\u8be6\u7ec6\u6b65\u9aa4\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ol>\n<li> <strong>\u83b7\u53d6\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\uff1a<\/strong>\u83b7\u53d6\u60a8\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u3002<\/li>\n<li> <strong>\u8c03\u7528 getBytes() \u65b9\u6cd5\uff1a<\/strong>\u4f7f\u7528 getBytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002\u8be5\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u5b57\u8282\u8868\u793a\u7684 byte[] \u6570\u7ec4\u3002<\/li>\n<\/ol>\n<p><strong>\u8bed\u6cd5\uff1a<\/strong><\/p>\n<pre>byte[] bytes = string.getBytes();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>String myString = \"Hello World\";\nbyte[] myBytes = myString.getBytes();<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7ed3\u679c\uff1a<\/strong><\/p>\n<p>myBytes \u5c06\u5305\u542b H, e, l, l, o, , W, o, r, l, d \u5b57\u8282\u7684\u6570\u7ec4\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong><\/p>\n<ul>\n<li>\u8f6c\u6362\u540e\u7684\u5b57\u8282\u6570\u7ec4\u5c06\u57fa\u4e8e\u5b57\u7b26\u96c6\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e3a UTF-8\uff09\u3002<\/li>\n<li>\u5982\u679c\u60a8\u9700\u8981\u4f7f\u7528\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\uff0c\u8bf7\u5728 getBytes() \u65b9\u6cd5\u4e2d\u6307\u5b9a\u5b57\u7b26\u96c6\u4f5c\u4e3a\u53c2\u6570\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5b57\u7b26\u600e\u4e48\u8f6c\u6362\u6210byte\u6570\u7ec4 java\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 java \u7f16\u7a0b\u8bed\u8a00\u5c06\u5b57\u7b26\u8f6c\u6362\u6210\u5b57\u8282\u6570\u7ec4\u7684\u65b9\u6cd5\uff1a\u83b7\u53d6\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u3002\u8c03\u7528 getbytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002\u8be5\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u5b57\u8282\u8868\u793a\u7684 byte[] \u6570\u7ec4\u3002 \u5982\u4f55\u5c06\u5b57\u7b26\u8f6c\u6362\u6210\u5b57\u8282\u6570\u7ec4\uff1f \u65b9\u6cd5\uff1a \u5bf9\u4e8e Java \u7f16\u7a0b\u8bed\u8a00\uff0c\u4f7f\u7528 getBytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002 \u8be6\u7ec6\u6b65\u9aa4\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u83b7\u53d6\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\uff1a\u83b7\u53d6\u60a8\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u3002 \u8c03\u7528 getBytes() \u65b9\u6cd5\uff1a\u4f7f\u7528 getBytes() \u65b9\u6cd5\u5c06\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5b57\u8282\u6570\u7ec4\u3002\u8be5\u65b9\u6cd5\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u5b57\u7b26\u6216\u5b57\u7b26\u4e32\u5b57\u8282\u8868\u793a\u7684 byte[] \u6570\u7ec4\u3002 \u8bed\u6cd5\uff1a byte[] bytes = string.getBytes(); \u767b\u5f55\u540e\u590d\u5236 \u793a\u4f8b\uff1a String myString = &#8220;Hello World&#8221;; byte[] myBytes = myString.getBytes(); \u767b\u5f55\u540e\u590d\u5236 \u7ed3\u679c\uff1a myBytes \u5c06\u5305\u542b H, e, l, l, o, , W, o, r, l, d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-39322","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=39322"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/39322\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=39322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=39322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=39322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}