{"id":1918,"date":"2017-02-15T19:37:20","date_gmt":"2017-02-15T11:37:20","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1918"},"modified":"2020-04-15T22:20:27","modified_gmt":"2020-04-15T14:20:27","slug":"java%e5%b7%a5%e7%a8%8b%e5%b8%88%e9%9d%a2%e8%af%95%e5%9f%ba%e7%a1%80%e7%af%87%ef%bc%88%e4%b8%80%ef%bc%89","status":"publish","type":"post","link":"https:\/\/ai.zhousir.top\/?p=1918","title":{"rendered":"Java\u5de5\u7a0b\u5e08\u9762\u8bd5\u57fa\u7840\u7bc7\uff08\u4e00\uff09"},"content":{"rendered":"<h2><a href=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/201407311445259040063.jpg\" rel=\"fancybox\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-2826\" src=\"https:\/\/ai.zhousir.top\/wp-content\/uploads\/2020\/04\/201407311445259040063.jpg\" alt=\"20140731144525904006\" width=\"383\" height=\"268\" \/><\/a><\/h2>\n<h2>\u524d\u8a00\uff1a<\/h2>\n<p>\u6211\u76f8\u4fe1\u6bcf\u4e00\u4e2a\u7a0b\u5e8f\u5458\u90fd\u662f\u4e3a\u4e86\u751f\u6d3b\u800c\u52aa\u529b\u7740\u7684\u3002\u5f88\u591a\u4eba\u56e0\u4e3a\u5174\u8da3\uff0c\u4ece\u6b64\u8e0f\u4e0a\u4e86\u8fd9\u6761\u2018\u70e7\u8111\u5927\u884c\u52a8\u2019\u7684\u91d1\u6865\uff1b\u4e5f\u6709\u5f88\u591a\u4eba\u56e0\u4e3a\u68a6\u60f3\u548c\u6267\u7740\uff0c\u594b\u4e0d\u987e\u8eab\u878d\u5165\u8fd9\u4e2a\u804c\u4e1a\uff1b\u8fd8\u6709\u5f88\u591a\u4eba\u56e0\u4e3a\u88ab\u73b0\u5b9e\u903c\u5f97\u592a\u65e0\u5948\uff0c\u4e0d\u5f97\u4e0d\u4e3a\u81ea\u5df1\u3001\u4e3a\u5bb6\u4eba\u3001\u4e3a\u672a\u6765\u8c0b\u8fd9\u4e48\u4e00\u6761\u574e\u5777\u7684\u8def\u3002<\/p>\n<p>\u8fd9\u91cc\uff0c\u6211\u4e0d\u53bb\u8bc4\u4ef7\u4ec0\u4e48\uff0c\u518d\u8bf4\u6211\u4e5f\u6ca1\u6709\u8d44\u683c\u53bb\u8bc4\u4ef7\u554a\u3002\u8a00\u5f52\u6b63\u4f20\uff0c\u4e0b\u9762\u6211\u5199\u8fd9\u7bc7\u6587\u7ae0\u7684\u5b9a\u4f4d\u662f\u5404\u4f4d\u5728\u573a\u7684\u8bfb\u8005\uff0c\u5982\u679c\u4f60\u8ba4\u4e3a\u6211\u63a5\u4e0b\u6765\u8bf4\u7684\u5185\u5bb9\u4f1a\u8ddf\u4e66\u91cc\u8bf4\u7684\u5dee\u4e0d\u591a\uff0c\u90a3\u4e48\u8bf7\u9ad8\u62ac\u8d35\u811a\u79fb\u6b65\u5b83\u5904\uff0c\u4f46\u662f\u6211\u76f8\u4fe1\u4f60\u7edd\u5bf9\u4e0d\u4f1a\u8fd9\u6837\u89c9\u5f97\u7684\u3002\u4e0d\u77e5\u9053\u4f5c\u4e3a\u7a0b\u5e8f\u5458\u7684\u4f60\u4eec\uff0c\u662f\u5426\u8fd8\u5728\u62b1\u7740\u9762\u8bd5\u6216\u8005\u7b14\u8bd5\u9898\u590d\u4e60\u5462\uff1f\u662f\u5426\u8fd8\u5728\u62b1\u7740\u5404\u79cd\u9762\u8bd5\u4e66\u4e71\u7ffb\u5462\uff1f<\/p>\n<p>\u6211\u53ea\u8bf4\u4e00\u70b9\uff0c\u9762\u8bd5\u7684\u76ee\u7684\u4e0d\u662f\u8ba9\u8003\u5b98\u77e5\u9053\u4f60\u600e\u4e48\u6837\uff0c\u800c\u662f\u8ba9\u4f60\u81ea\u5df1\u6e05\u695a\u81ea\u5df1\u600e\u4e48\u6837\u3002\u4e5f\u5c31\u662f\u8bf4\u4f60\u4f1a\u4ec0\u4e48\u3001\u80fd\u591f\u505a\u4ec0\u4e48\uff01\u4e3e\u4e2a\u4f8b\u5b50\uff0c\u5982\u679c\u4f60\u53bb\u9762\u8bd5Java\u5de5\u7a0b\u5e08\uff0c\u4f60\u81f3\u5c11\u8981\u4f1a\u8be5\u804c\u4f4d\u7684\u804c\u80fd\uff0c\u800c\u4e0d\u662f\u53ea\u4f1a\u9762\u9762\u8bd5\u3001\u505a\u505a\u7b14\u8bd5\u9898\u3002\u6240\u4ee5\uff0c\u8fd9\u5c31\u662f\u6211\u5199\u8fd9\u7bc7\u6587\u7ae0\u7684\u521d\u8877\uff01<\/p>\n<div class=\"image-package\"><img decoding=\"async\" src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-438fd2f3d67b7f2e.jpg?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"\" data-original-src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-438fd2f3d67b7f2e.jpg?imageMogr2\/auto-orient\/strip%7CimageView2\/2\" \/><\/div>\n<hr \/>\n<h1>\u4e00\u3001\u57fa\u7840\u7bc7<\/h1>\n<h3>1.\u9762\u5411\u5bf9\u8c61\u7684\u4e09\u5927\u7279\u6027<\/h3>\n<p><strong>\u7ee7\u627f\u3001\u5c01\u88c5\u3001\u591a\u6001<\/strong><\/p>\n<p><strong><em>\u4ec0\u4e48\u662f\u7ee7\u627f\uff1f<\/em><\/strong><br \/>\n\u2460\u7ee7\u627f\u662f\u9762\u5411\u5bf9\u8c61\u7a0b\u5e8f\u8bbe\u8ba1\u80fd\u591f\u63d0\u9ad8\u8f6f\u4ef6\u5f00\u53d1\u6548\u7387\u7684\u91cd\u8981\u539f\u56e0\u4e4b\u4e00\u3002<br \/>\n\u2461\u7ee7\u627f\u662f\u5177\u6709\u4f20\u9012\u6027\u7684\uff0c\u5c31\u50cf\u73b0\u5b9e\u4e2d\u5b59\u5b50\u4e0d\u4ec5\u957f\u5f97\u50cf\u7238\u7238\u800c\u4e14\u8fd8\u50cf\u4ed6\u7237\u7237\u3002<br \/>\n\u2462\u7ee7\u627f\u6765\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u662f\u9690\u5f0f\u7684\uff0c\u4e5f\u5c31\u662f\u5728\u672c\u7c7b\u91cc\u9762\u662f\u770b\u4e0d\u89c1\u7684\u3002<br \/>\n\u2463\u4e00\u4e2a\u7c7b\u53ea\u80fd\u6709\u4e00\u4e2a\u7236\u7c7b\uff0c\u4e5f\u5c31\u662f\u7c7b\u53ea\u80fd\u662f\u5355\u7ee7\u627f\u3002<br \/>\n\u2464\u4e00\u4e2a\u63a5\u53e3\u53ef\u4ee5\u6709\u591a\u4e2a\u7236\u7c7b\uff0c\u4e5f\u5c31\u662f\u63a5\u53e3\u53ef\u4ee5\u662f\u591a\u7ee7\u627f\u3002<br \/>\n\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u4e2d\uff0c\u4e00\u4e2a\u7c7b\u7ee7\u627f\u4e8e\u53e6\u4e00\u4e2a\u7c7b\uff0c\u90a3\u4e48\u524d\u8005\u5c31\u662f\u540e\u8005\u7684\u5b50\u7c7b\uff0c\u53cd\u5219\u53cd\u4e4b\u3002<\/p>\n<p><strong><em>\u4ec0\u4e48\u662f\u5c01\u88c5\uff1f<\/em><\/strong><br \/>\n\u5bf9\u8c61\u6570\u636e\u548c\u64cd\u4f5c\u8be5\u5bf9\u8c61\u7684\u6307\u4ee4\u90fd\u662f\u5bf9\u8c61\u81ea\u8eab\u7684\u4e00\u90e8\u5206\uff0c\u80fd\u591f\u5b9e\u73b0\u5c3d\u53ef\u80fd\u5bf9\u5916\u90e8\u9690\u85cf\u6570\u636e\u3002<br \/>\n\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u4e2d\uff0c\u4f7f\u7528\u5c01\u88c5\u6700\u591a\u7684\u5c31\u662f\u5b9e\u4f53\u7c7b\uff0c\u5e38\u5e38\u548cJavaBean\uff08\u7c7b\u5fc5\u987b\u662f\u5177\u4f53\u7684\u548c\u516c\u5171\u7684\uff0c\u5e76\u4e14\u5177\u6709\u65e0\u53c2\u6570\u7684\u6784\u9020\u5668\uff09\u4e00\u8d77\u4f7f\u7528\u3002<br \/>\n\u90a3\u4e48\uff0c\u5b9e\u4f53\u7c7b\u6709\u90a3\u4e9b\u4e1c\u897f\u5462\uff1f<br \/>\n\u7b54\uff1a\u79c1\u6709\u7684\u6210\u5458\u53d8\u91cf\u3001\u65e0\u53c2\u6570\u7684\u6784\u9020\u5668\u3001\u6709\u53c2\u6570\u7684\u6784\u9020\u5668\u3001setter\u548cgetters\u65b9\u6cd5\u3001\u91cd\u5199tostring\u65b9\u6cd5\u3001\u91cd\u5199hashCode\u548cequals\u65b9\u6cd5\u3002<\/p>\n<p><strong><em>\u4ec0\u4e48\u662f\u591a\u6001\uff1f<\/em><\/strong><br \/>\n\u2460\u591a\u6001\u5c31\u662f\u5bf9\u8c61\u62e5\u6709\u591a\u79cd\u5f62\u6001\uff1a\u5f15\u7528\u591a\u6001\u548c\u65b9\u6cd5\u591a\u6001\u3002<br \/>\n\u2461\u5f15\u7528\u591a\u6001\uff1a\u7236\u7c7b\u7684\u5f15\u7528\u53ef\u4ee5\u6307\u5411\u672c\u7c7b\u5bf9\u8c61\u3001\u7236\u7c7b\u7684\u5f15\u7528\u53ef\u4ee5\u6307\u5411\u5b50\u7c7b\u7684\u5bf9\u8c61\u3002<br \/>\n\u2462\u65b9\u6cd5\u591a\u6001\uff1a\u521b\u5efa\u672c\u7c7b\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528\u7684\u65b9\u6cd5\u4e3a\u672c\u7c7b\u7684\u65b9\u6cd5\uff1b\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\u65f6\uff0c\u8c03\u7528\u7684\u65b9\u6cd5\u4e3a\u5b50\u7c7b\u91cd\u5199\u7684\u65b9\u6cd5\u6216\u8005\u7ee7\u627f\u7684\u65b9\u6cd5\u3002<br \/>\n\u2463\u5b58\u5728\u591a\u6001\u7684\u5fc5\u8981\u6761\u4ef6\uff1a\u7ee7\u627f\u3001\u91cd\u5199\u3002<br \/>\n\u2464\u591a\u6001\u7684\u4f5c\u7528\u662f\u6d88\u9664\u7c7b\u578b\u4e4b\u95f4\u7684\u8026\u5408\u5173\u7cfb\u3002<br \/>\n\u5728\u5b9e\u9645\u9879\u76ee\u5f00\u53d1\u4e2d\uff0cA\u7c7b\u7ee7\u627fB\u7c7b\uff0c\u5982\u679c\u5728A\u7c7b\u4e2d\u4e0d\u91cd\u5199B\u7c7b\u7684\u65b9\u6cd5\u7684\u65f6\u5019\uff0c\u8f93\u51fa\u7684\u4ecd\u65e7\u662fB\u7c7b\u65b9\u6cd5\u91cc\u9762\u7684\u4fe1\u606f\uff08B b=new A()\uff09\uff1b\u5982\u679c\u5728A\u7c7b\u4e2d\u91cd\u5199B\u7c7b\u7684\u65b9\u6cd5\u7684\u65f6\u5019\uff0c\u8f93\u51fa\u7684\u662fA\u7c7b\u65b9\u6cd5\u91cc\u9762\u7684\u4fe1\u606f\uff08B b=new A()\uff09\u3002<\/p>\n<h3>2.Java\u96c6\u5408\u6846\u67b6\u6811<\/h3>\n<div class=\"image-package\"><img decoding=\"async\" src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-76238a99166dd81d.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"\" data-original-src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-76238a99166dd81d.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\" \/><\/p>\n<div class=\"image-caption\">java\u96c6\u5408\u6846\u67b6\u6210\u5458.png<\/div>\n<\/div>\n<p><strong>Collection\u63a5\u53e3<\/strong>\uff1a\u5b83\u662fJava\u96c6\u5408\u6846\u67b6\u7684\u4e00\u4e2a\u6839\u63a5\u53e3\uff0c\u4e5f\u662fList\u3001Set\u548cQueue\u63a5\u53e3\u7684\u7236\u63a5\u53e3\u3002\u540c\u65f6\u5b83\u5b9a\u4e49\u4e86\u53ef\u7528\u4e8e\u64cd\u4f5cList\u3001Set\u548cQueue\u7684\u65b9\u6cd5\u2014\u589e\u5220\u6539\u67e5\u3002<\/p>\n<p><strong>Map\u63a5\u53e3<\/strong>\uff1a\u5b83\u63d0\u4f9b\u4e86\u4e00\u79cd\u6620\u5c04\u5173\u7cfb\uff0c\u5176\u4e2d\u7684\u5143\u7d20\u662f\u4ee5\u952e\u503c\u5bf9\uff08key-value\uff09\u7684\u5f62\u5f0f\u5b58\u50a8\u7684\u3002Map\u63a5\u53e3\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u5b9e\u73b0\u7c7bHashMap\u3002<br \/>\n\u2460\u5728Map\u63a5\u53e3\u4e2d\u7684\u952e\u503c\u5bf9\u662f\u4ee5Entry\u7c7b\u578b\u7684\u5bf9\u8c61\u5b9e\u4f8b\u5f62\u5f0f\u5b58\u5728\u3002<br \/>\n\u2461\u5728Map\u63a5\u53e3\u4e2d\u952e\u503c\uff08Key\u503c\uff09\u662f\u4e0d\u53ef\u4ee5\u91cd\u590d\u7684\uff0cvalue\u503c\u5374\u53ef\u4ee5\u91cd\u590d\uff0c\u4e5f\u5c31\u662f\u5b58\u5728\u591a\u5bf9\u4e00\u7684\u5173\u7cfb\u3002<br \/>\n\u2462\u5728Map\u63a5\u53e3\u4e2d\u63d0\u4f9b\u4e86\u5206\u522b\u8fd4\u56deKey\u503c\u7684\u96c6\u5408\u3001value\u503c\u7684\u96c6\u5408\u4ee5\u53caEntry\u96c6\u5408\u7684\u65b9\u6cd5\u3002<br \/>\n\u2463Map\u652f\u6301\u6cdb\u578b\uff0c\u540c\u65f6Key\u503c\u548cvalue\u503c\u90fd\u662f\u53ef\u4ee5\u4e3anull\u7684\u3002<br \/>\n\u2464\u5728HashMap\u4e2d\u7684Entry\u5bf9\u8c61\u662f\u65e0\u5e8f\u6392\u5e8f\u7684\uff0c\u8fd9\u70b9\u7279\u6027\u548cList\u63a5\u53e3\u662f\u76f8\u53cd\u7684\u3002<br \/>\n\u2465\u5728HashMap\u4e2d\u6709\u4e14\u53ea\u80fd\u6709\u4e00\u4e2aKey\u503c\u4e3anull\u7684\u6620\u5c04\u3002\uff08\u6ce8\uff1akey\u503c\u662f\u4e0d\u80fd\u91cd\u590d\u7684\uff09<\/p>\n<p><strong>List\u63a5\u53e3<\/strong>\uff1aList\u63a5\u53e3\u6709\u4e00\u4e2a\u91cd\u8981\u7684\u5b9e\u73b0\u7c7bArrayList\uff08\u6570\u7ec4\u5e8f\u5217\uff09\u3002<br \/>\n\u2460List\u662f\u5143\u7d20\u6709\u5e8f\u5e76\u4e14\u53ef\u4ee5\u91cd\u590d\u7684\u96c6\u5408\u3002<br \/>\n\u2461List\u53ef\u4ee5\u7cbe\u786e\u7684\u63a7\u5236\u6bcf\u4e2a\u5143\u7d20\u7684\u63d2\u5165\u4f4d\u7f6e\uff0c\u6216\u5220\u9664\u67d0\u4e2a\u5143\u7d20\u7684\u4f4d\u7f6e\u3002<\/p>\n<p><strong>Comparator\u63a5\u53e3<\/strong>\uff1a\u4e34\u65f6\u7684\u6bd4\u8f83\u89c4\u5219\u3002\u5982\u679c\u67d0\u4e00\u4e2a\u7c7b\u8981\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3\uff0c\u90a3\u5fc5\u7136\u8981\u5b9e\u73b0\u5b83\u7684Compare()\u65b9\u6cd5\u3002<\/p>\n<p><strong>Comparable\u63a5\u53e3<\/strong>\uff1a\u9ed8\u8ba4\u7684\u6bd4\u8f83\u89c4\u5219\u3002\u5f53\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u63a5\u53e3\uff0c\u5219\u8868\u793a\u8fd9\u4e2a\u7c7b\u7684\u5b9e\u4f8b\u53ef\u4ee5\u6bd4\u8f83\u5927\u5c0f\uff0c\u53ef\u4ee5\u8fdb\u884c\u81ea\u7136\u6392\u5e8f\u3002\u5982\u679c\u67d0\u4e00\u4e2a\u7c7b\u8981\u5b9e\u73b0\u8fd9\u4e2a\u63a5\u53e3\uff0c\u90a3\u5fc5\u7136\u8981\u5b9e\u73b0\u5b83\u7684CompareTo()\u65b9\u6cd5\u3002<\/p>\n<h3>3.Java\u4e2d\u7684IO\u6d41<\/h3>\n<p><strong>\u5b57\u8282\u6d41<\/strong>\uff1a<\/p>\n<pre class=\"hljs ceylon\"><code class=\"ceylon\"><span class=\"hljs-comment\">\/\/\u4e00\u4e2a\u5b57\u8282\u4e00\u4e2a\u5b57\u8282\u7684\u8bfb\u5199<\/span>\r\nFileInputStream <span class=\"hljs-keyword\">in<\/span>=<span class=\"hljs-keyword\">new<\/span> FileInputStream(<span class=\"hljs-string\">\"\u6e90\u6587\u4ef6\"<\/span>);\r\nFileOutputStream <span class=\"hljs-keyword\">out<\/span>=<span class=\"hljs-keyword\">new<\/span> FileOutputStream(<span class=\"hljs-string\">\"\u76ee\u6807\u6587\u4ef6\"<\/span>);\r\n......\r\n<span class=\"hljs-keyword\">in<\/span>.close();\r\n<span class=\"hljs-keyword\">out<\/span>.close();<\/code><\/pre>\n<p>\u9996\u5148\u8981\u8bb0\u4f4f\uff0c\u4e00\u65e6\u4f7f\u7528\u4e86IO\u6d41\u6700\u540e\u4e00\u5b9a\u8981\u8bb0\u5f97\u5173\u95ed\uff0c\u8fd9\u662f\u5e38\u8bc6\u3002<\/p>\n<pre class=\"hljs haxe\"><code class=\"haxe\"><span class=\"hljs-comment\">\/\/\u5229\u7528\u7f13\u51b2\u533a\uff0c\u9ad8\u6548\u7684\u8bfb\u53d6\u5b57\u8282<\/span>\r\nBufferedInputStream <span class=\"hljs-keyword\">in<\/span>=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">BufferedInputStream<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileInputStream<\/span>(<span class=\"hljs-string\">\"\u6e90\u6587\u4ef6\"<\/span>);\r\nBufferedOutputStream out=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">BufferedOutputStream<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileOutputStream<\/span>(<span class=\"hljs-string\">\"\u76ee\u6807\u6587\u4ef6\"<\/span>);\r\n......\r\n<span class=\"hljs-keyword\">in<\/span>.close();\r\nout.close();<\/code><\/pre>\n<p><strong>\u5b57\u7b26\u6d41<\/strong>\uff1a<\/p>\n<pre class=\"hljs haxe\"><code class=\"haxe\">InputStreamReader isr=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">InputStreamReader<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileInputStream<\/span>(<span class=\"hljs-string\">\"\u6e90\u6587\u4ef6\u8def\u5f84\"<\/span>),<span class=\"hljs-string\">\"\u8bbe\u7f6e\u7f16\u7801\"<\/span>);\r\nOutputStreamWriter osw=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">OutputStreamWriter<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileOutputStream<\/span>(<span class=\"hljs-string\">\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\"<\/span>),<span class=\"hljs-string\">\"\u8bbe\u7f6e\u7f16\u7801\"<\/span>);\r\n......\r\nosw.close();\r\nisr.close();<\/code><\/pre>\n<p>\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<pre class=\"hljs abnf\"><code class=\"abnf\">FileReader fr=new FileReader(<span class=\"hljs-string\">\"\u6e90\u6587\u4ef6\u8def\u5f84\"<\/span>)<span class=\"hljs-comment\">;<\/span>\r\nFileWriter fw=new FileWriter(<span class=\"hljs-string\">\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\"<\/span>)<span class=\"hljs-comment\">;<\/span>\r\n......\r\nfr.close()<span class=\"hljs-comment\">;<\/span>\r\nfw.close()<span class=\"hljs-comment\">;<\/span><\/code><\/pre>\n<pre class=\"hljs haxe\"><code class=\"haxe\"><span class=\"hljs-comment\">\/\/\u5229\u7528\u7f13\u51b2\u533a\uff0c\u9ad8\u6548\u7684\u8bfb\u53d6\u5b57\u7b26<\/span>\r\nBufferedReader br=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">BufferedReader<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileReade<\/span>(<span class=\"hljs-string\">\"\u6e90\u6587\u4ef6\u8def\u5f84\"<\/span>);\r\nPrintWriter pw=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">PrintWriter<\/span>(<span class=\"hljs-string\">\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\"<\/span>);\r\n......\r\nbr.close();\r\npw.close();<\/code><\/pre>\n<p><strong>\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/strong>\uff1a<\/p>\n<pre class=\"hljs haxe\"><code class=\"haxe\"><span class=\"hljs-comment\">\/\/\u5bf9\u8c61\u7684\u5e8f\u5217\u5316<\/span>\r\nObjectOutputStream oos=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">ObjectOutputStream<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileOutputStream<\/span>(file));<\/code><\/pre>\n<p>\u8fd9\u91cc\u7684file\u6307\u7684\u662f<code>String file=\"\u6587\u4ef6\u5728\u9879\u76ee\u4e2d\u7684\u8def\u5f84\";<\/code><\/p>\n<pre class=\"hljs haxe\"><code class=\"haxe\"><span class=\"hljs-comment\">\/\/\u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316<\/span>\r\nObjectInputStream ois=<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">ObjectInputStream<\/span>(<span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-type\">FileInputStream<\/span>(file));<\/code><\/pre>\n<h3>4.Java\u7684Socket\u901a\u4fe1\uff08\u591a\u7ebf\u7a0b\uff09<\/h3>\n<div class=\"image-package\"><img decoding=\"async\" src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-d97a431a247c598e.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"\" data-original-src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-d97a431a247c598e.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\" \/><\/p>\n<div class=\"image-caption\">Socket\u901a\u4fe1\u6a21\u578b.png<\/div>\n<\/div>\n<p>\u601d\u8def\uff1a<br \/>\n\u2460\u9996\u5148\u521b\u5efa\u670d\u52a1\u5668\u7aefSocket\uff0c\u6307\u5b9a\u5e76\u4fa6\u542c\u67d0\u4e00\u4e2a\u7aef\u53e3\uff0c\u7136\u540e\u5faa\u73af\u76d1\u542c\u5f00\u59cb\u7b49\u5f85\u5ba2\u6237\u7aef\u7684\u8fde\u63a5&#8230;.<br \/>\n\u2461\u521b\u5efa\u5ba2\u6237\u7aefsocket\uff0c\u6307\u5b9a\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3\uff0c\u7136\u540e\u83b7\u53d6\u8f93\u51fa\u6d41\uff0c\u5411\u670d\u52a1\u5668\u7aef\u53d1\u9001\u8bf7\u6c42\uff0c\u5e76\u5173\u95edsocket\u8f93\u51fa\u6d41\u3002<br \/>\n\u2462\u670d\u52a1\u7aef\u63a5\u6536\u5230\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u540e\uff0c\u521b\u5efa\u65b0\u7ebf\u7a0b\u5e76\u542f\u52a8\u3002<br \/>\n\u2463\u521b\u5efa\u7ebf\u7a0b\u5904\u7406\u7c7b\uff0c\u6267\u884c\u7ebf\u7a0b\u64cd\u4f5c\uff0c\u83b7\u53d6\u8f93\u5165\u6d41\uff0c\u670d\u52a1\u7aef\u8bfb\u53d6\u5ba2\u6237\u7aef\u7528\u6237\u8be6\u60c5\uff0c\u5173\u95ed\u8d44\u6e90\u3002<br \/>\n\u2464\u6267\u884c\u7ebf\u7a0b\u64cd\u4f5c\uff0c\u83b7\u53d6\u8f93\u51fa\u6d41\uff0c\u54cd\u5e94\u5ba2\u6237\u7aef\u8bf7\u6c42\uff0c\u5ba2\u6237\u7aef\u63a5\u53d7\u5230\u670d\u52a1\u7aef\u7684\u54cd\u5e94\uff0c\u5173\u95ed\u8d44\u6e90\u3002<\/p>\n<p>\u7b80\u5355\u70b9\u8bb2\uff0c\u5c31\u76f8\u5f53\u4e8e\u6211\u8ddf\u4f60\u8bf4\u8bdd\uff08\u5ba2\u6237\u7aef\u2192\u670d\u52a1\u7aef\uff09\uff0c\u4f60\u6536\u5230\u6211\u8bf4\u7684\u8bdd\uff08\u670d\u52a1\u7aef\u2192\u7ebf\u7a0b\u5904\u7406\u7c7b\uff09\uff0c\u5927\u8111\u8fdb\u884c\u601d\u8003\u540e\uff08\u7ebf\u7a0b\u5904\u7406\u7c7b\uff09\uff0c\u505a\u51fa\u56de\u7b54\u6211\u7684\u8bdd\uff08\u7ebf\u7a0b\u5904\u7406\u7c7b\u2192\u5ba2\u6237\u7aef\uff09\u3002<\/p>\n<h3>5.\u5173\u7cfb\u578b\u6570\u636e\u5e93<\/h3>\n<p><strong>\u6570\u636e\u5e93\u7684\u4e09\u8303\u5f0f<\/strong>\uff1a<br \/>\n\u2460\u5b57\u6bb5\u4e0d\u53ef\u5206\u3002<br \/>\n\u2461\u6709\u4e3b\u952e\uff0c\u975e\u4e3b\u952e\u5b57\u6bb5\u4f9d\u8d56\u4e3b\u952e\u3002<br \/>\n\u2462\u975e\u4e3b\u952e\u5b57\u6bb5\u4e0d\u80fd\u4e92\u76f8\u4f9d\u8d56\u3002<\/p>\n<p><strong>T-SQL<\/strong>\uff1a<\/p>\n<div class=\"image-package\"><img decoding=\"async\" src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-aeaf17a9cc28f94a.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\/w\/1240\" alt=\"\" data-original-src=\"http:\/\/upload-images.jianshu.io\/upload_images\/4259662-aeaf17a9cc28f94a.png?imageMogr2\/auto-orient\/strip%7CimageView2\/2\" \/><\/p>\n<div class=\"image-caption\">T-SQL\u7b80\u4ecb.png<\/div>\n<\/div>\n<p>\u5728\u6574\u4e2a\u6570\u636e\u5e93\u4e2d\uff0c\u67e5\u8be2\u64cd\u4f5c\u5360\u636e\u589e\u5220\u6539\u67e5\u768480%\uff0c\u800c\u8bf4\u5230\u67e5\u8be2\uff0cT-SQL\u8bed\u53e5\u81ea\u7136\u4e0d\u80fd\u5c11\u3002\u5982\u56fe\u4e0a\u793a\u3002<\/p>\n<p><strong>\u589e<\/strong>\uff1a<br \/>\n\u2460\u63d2\u5165\u5355\u884c<br \/>\n<code>insert into &lt;\u8868\u540d&gt; (\u5217\u540d) values (\u5217\u503c)<\/code><br \/>\n\u2461\u5c06\u73b0\u6709\u7684\u8868\u6570\u636e\u6dfb\u52a0\u5230\u4e00\u4e2a\u5df2\u6709\u8868<br \/>\n<code>insert into &lt;\u5df2\u6709\u7684\u65b0\u8868&gt; (\u5217\u540d) select &lt;\u6e90\u8868\u5217\u540d&gt; from &lt;\u6e90\u8868\u540d&gt;<\/code><br \/>\n\u2462\u76f4\u63a5\u62ff\u73b0\u6709\u8868\u6570\u636e\u521b\u5efa\u4e00\u4e2a\u65b0\u8868\u5e76\u586b\u5145<br \/>\n<code>select &lt;\u65b0\u5efa\u8868\u5217\u540d&gt; into &lt;\u65b0\u5efa\u8868\u540d&gt; from &lt;\u6e90\u8868\u540d&gt;<\/code><\/p>\n<p><strong>\u5220<\/strong>\uff1a<br \/>\n\u2460\u5220\u9664\u6ee1\u8db3\u6761\u4ef6\u7684\u884c<br \/>\n<code>delete from &lt;\u8868\u540d&gt; where &lt;\u5220\u9664\u6761\u4ef6&gt;<\/code><br \/>\n\u2461\u5220\u9664\u6574\u4e2a\u8868<br \/>\n<code>truncate table &lt;\u8868\u540d&gt;<\/code><\/p>\n<blockquote><p>\u6ce8\uff1a\u5220\u9664\u8868\u7684\u6240\u6709\u884c\uff0c\u4f46\u8868\u7684\u7ed3\u6784\u3001\u5217\u3001\u7ea6\u675f\u3001\u7d22\u5f15\u7b49\u4e0d\u4f1a\u88ab\u5220\u9664\uff1b\u4e0d\u80fd\u7528\u8bed\u6709\u5916\u5efa\u7ea6\u675f\u5f15\u7528\u7684\u8868\u3002<\/p><\/blockquote>\n<p><strong>\u6539<\/strong>\uff1a<br \/>\n\u2460\u66f4\u65b0<br \/>\n<code>update &lt;\u8868\u540d&gt; set &lt;\u5217\u540d=\u66f4\u65b0\u503c&gt; where &lt;\u66f4\u65b0\u6761\u4ef6&gt;<\/code><\/p>\n<p><strong>\u5b50\u67e5\u8be2<\/strong>\uff1a<br \/>\n<code>SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);<\/code><\/p>\n<p>\u5176\u4e2d\uff1a<br \/>\n\u2460SELECT * FROM t1 &#8230;\u79f0\u4e3a\u5916\u67e5\u8be2\u3002<br \/>\n\u2461SELECT column1 FROM t2 \u79f0\u4e3a\u5b50\u67e5\u8be2\u3002<br \/>\n\u6240\u4ee5\uff0c\u6211\u4eec\u5c31\u8bf4\u5b50\u67e5\u8be2\u662f\u5d4c\u5957\u5728\u5916\u67e5\u8be2\u5185\u90e8\u7684\u3002\u800c\u4e8b\u5b9e\u4e0a\u5b83\u4e5f\u6709\u53ef\u80fd\u5728\u5b50\u67e5\u8be2\u5185\u90e8\u518d\u5d4c\u5957\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u5b50\u67e5\u8be2\u3002\u8fd9\u91cc\u8981\u6ce8\u610f\uff0c\u5b50\u67e5\u8be2\u5fc5\u987b\u51fa\u73b0\u5728\u5706\u62ec\u53f7\u4e4b\u95f4\u54e6\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8f6c\u81f3:http:\/\/www.jianshu.com\/p\/e4ba72acffa9#<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\uff1a \u6211\u76f8\u4fe1\u6bcf\u4e00\u4e2a\u7a0b\u5e8f\u5458\u90fd\u662f\u4e3a\u4e86\u751f\u6d3b\u800c\u52aa\u529b\u7740\u7684\u3002\u5f88\u591a\u4eba\u56e0\u4e3a\u5174\u8da3\uff0c\u4ece\u6b64\u8e0f\u4e0a\u4e86\u8fd9\u6761\u2018\u70e7\u8111\u5927\u884c\u52a8\u2019\u7684\u91d1\u6865\uff1b\u4e5f\u6709\u5f88\u591a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[46],"tags":[],"_links":{"self":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1918"}],"collection":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1918"}],"version-history":[{"count":5,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1918\/revisions"}],"predecessor-version":[{"id":2834,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=\/wp\/v2\/posts\/1918\/revisions\/2834"}],"wp:attachment":[{"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ai.zhousir.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}