{"id":1918,"date":"2017-02-15T19:37:20","date_gmt":"2017-02-15T11:37:20","guid":{"rendered":"https:\/\/ai.zhousir.top\/?p=1918"},"modified":"2026-08-18T12:09:37","modified_gmt":"2026-08-18T04:09:37","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":"<section id=\"wenyan\" style=\"font-family: system-ui, 'Apple Color Emoji', 'Segoe UI', 'Segoe UI Symbol', 'Noto Sans', Roboto, sans-serif; line-height: 1.75; font-size: 16px; color: #000000; caret-color: #000000;\" data-provider=\"WenYan\">\n<p style=\"margin: 1em 0px;\">\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\u8e0f\u4e0a\u8fd9\u6761\u201c\u70e7\u8111\u201d\u8def\uff1b\u4e5f\u6709\u4eba\u56e0\u4e3a\u68a6\u60f3\u548c\u6267\u7740\uff1b\u8fd8\u6709\u4eba\u88ab\u73b0\u5b9e\u903c\u7740\uff0c\u4e3a\u81ea\u5df1\u3001\u4e3a\u5bb6\u4eba\u8c0b\u8fd9\u4e48\u4e00\u6761\u574e\u5777\u7684\u8def\u3002\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\u4f60\u4f1a\u4ec0\u4e48\u3001\u80fd\u591f\u505a\u4ec0\u4e48\u3002\u53bb\u9762 Java \u5de5\u7a0b\u5e08\uff0c\u81f3\u5c11\u8981\u4f1a\u8be5\u804c\u4f4d\u7684\u804c\u80fd\uff0c\u800c\u4e0d\u662f\u53ea\u4f1a\u80cc\u9898\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><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><\/p>\n<p style=\"margin: 1em 0px;\">\u4e0b\u9762\u6309\u57fa\u7840\u7bc7\u6574\u7406\uff1a\u9762\u5411\u5bf9\u8c61\u3001\u96c6\u5408\u3001IO\u3001Socket\u3001\u5173\u7cfb\u578b\u6570\u636e\u5e93\u3002\u82e5\u4f60\u89c9\u5f97\u4f1a\u548c\u4e66\u4e0a\u5dee\u4e0d\u591a\uff0c\u53ef\u4ee5\u5148\u5bf9\u7167\u81ea\u5df1\u4f1a\u4e0d\u4f1a\u52a8\u624b\u5199\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><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\" \/><\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e00\u3001\u9762\u5411\u5bf9\u8c61\u7684\u4e09\u5927\u7279\u6027<\/h2>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u7ee7\u627f\u3001\u5c01\u88c5\u3001\u591a\u6001<\/strong>\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4ec0\u4e48\u662f\u7ee7\u627f\uff1f<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u7ee7\u627f\u662f\u9762\u5411\u5bf9\u8c61\u80fd\u63d0\u9ad8\u8f6f\u4ef6\u5f00\u53d1\u6548\u7387\u7684\u91cd\u8981\u539f\u56e0\u4e4b\u4e00\u3002<\/section>\n<\/li>\n<li>\n<section>\u7ee7\u627f\u5177\u6709\u4f20\u9012\u6027\uff0c\u50cf\u5b59\u5b50\u4e0d\u4ec5\u50cf\u7238\u7238\u8fd8\u50cf\u7237\u7237\u3002<\/section>\n<\/li>\n<li>\n<section>\u7ee7\u627f\u6765\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u662f\u9690\u5f0f\u7684\uff0c\u5728\u672c\u7c7b\u91cc\u770b\u4e0d\u89c1\u3002<\/section>\n<\/li>\n<li>\n<section>\u7c7b\u53ea\u80fd\u5355\u7ee7\u627f\uff1a\u4e00\u4e2a\u7c7b\u53ea\u80fd\u6709\u4e00\u4e2a\u7236\u7c7b\u3002<\/section>\n<\/li>\n<li>\n<section>\u4e00\u4e2a\u63a5\u53e3\u53ef\u4ee5\u6709\u591a\u4e2a\u7236\u63a5\u53e3\uff0c\u63a5\u53e3\u53ef\u4ee5\u591a\u7ee7\u627f\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u5b9e\u9645\u9879\u76ee\u4e2d\uff0cA \u7ee7\u627f B\uff0c\u5219 A \u662f B \u7684\u5b50\u7c7b\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4ec0\u4e48\u662f\u5c01\u88c5\uff1f<\/h3>\n<p style=\"margin: 1em 0px;\">\u5bf9\u8c61\u6570\u636e\u548c\u64cd\u4f5c\u8be5\u5bf9\u8c61\u7684\u6307\u4ee4\u90fd\u662f\u5bf9\u8c61\u81ea\u8eab\u7684\u4e00\u90e8\u5206\uff0c\u5c3d\u53ef\u80fd\u5bf9\u5916\u90e8\u9690\u85cf\u6570\u636e\u3002\u9879\u76ee\u91cc\u5c01\u88c5\u7528\u5f97\u6700\u591a\u7684\u662f\u5b9e\u4f53\u7c7b\uff0c\u5e38\u548c JavaBean \u4e00\u8d77\u7528\uff1a\u7c7b\u5fc5\u987b\u5177\u4f53\u4e14 public\uff0c\u5e76\u6709\u65e0\u53c2\u6784\u9020\u5668\u3002\u5b9e\u4f53\u7c7b\u901a\u5e38\u5305\u542b\uff1a\u79c1\u6709\u6210\u5458\u53d8\u91cf\u3001\u65e0\u53c2\/\u6709\u53c2\u6784\u9020\u5668\u3001setter\/getter\u3001\u91cd\u5199 toString\u3001\u91cd\u5199 hashCode \u548c equals\u3002<\/p>\n<h3 style=\"padding: 0px; color: #4870ac; margin: 1.2em 0px 1em; font-size: 1.3em;\">\u4ec0\u4e48\u662f\u591a\u6001\uff1f<\/h3>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5bf9\u8c61\u62e5\u6709\u591a\u79cd\u5f62\u6001\uff1a\u5f15\u7528\u591a\u6001\u548c\u65b9\u6cd5\u591a\u6001\u3002<\/section>\n<\/li>\n<li>\n<section>\u5f15\u7528\u591a\u6001\uff1a\u7236\u7c7b\u5f15\u7528\u53ef\u6307\u5411\u672c\u7c7b\u5bf9\u8c61\uff0c\u4e5f\u53ef\u6307\u5411\u5b50\u7c7b\u5bf9\u8c61\u3002<\/section>\n<\/li>\n<li>\n<section>\u65b9\u6cd5\u591a\u6001\uff1a\u521b\u5efa\u672c\u7c7b\u5bf9\u8c61\u65f6\u8c03\u672c\u7c7b\u65b9\u6cd5\uff1b\u521b\u5efa\u5b50\u7c7b\u5bf9\u8c61\u65f6\u8c03\u5b50\u7c7b\u91cd\u5199\u7684\u65b9\u6cd5\u6216\u7ee7\u627f\u7684\u65b9\u6cd5\u3002<\/section>\n<\/li>\n<li>\n<section>\u5fc5\u8981\u6761\u4ef6\uff1a\u7ee7\u627f\u3001\u91cd\u5199\u3002<\/section>\n<\/li>\n<li>\n<section>\u4f5c\u7528\u662f\u6d88\u9664\u7c7b\u578b\u4e4b\u95f4\u7684\u8026\u5408\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">A \u7ee7\u627f B\uff1aA \u4e0d\u91cd\u5199 B \u7684\u65b9\u6cd5\u65f6\uff0c<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">B b = new A()<\/code> \u8f93\u51fa\u4ecd\u662f B \u65b9\u6cd5\u91cc\u7684\u4fe1\u606f\uff1bA \u91cd\u5199\u540e\uff0c\u540c\u6837\u5199\u6cd5\u8f93\u51fa A \u65b9\u6cd5\u91cc\u7684\u4fe1\u606f\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e8c\u3001Java \u96c6\u5408\u6846\u67b6\u6811<\/h2>\n<p style=\"margin: 1em 0px;\"><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<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">Collection \u63a5\u53e3<\/strong>\uff1a\u96c6\u5408\u6846\u67b6\u7684\u6839\u63a5\u53e3\u4e4b\u4e00\uff0c\u4e5f\u662f List\u3001Set \u548c Queue \u7684\u7236\u63a5\u53e3\uff0c\u5b9a\u4e49\u589e\u5220\u6539\u67e5\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">Map \u63a5\u53e3<\/strong>\uff1a\u63d0\u4f9b\u6620\u5c04\u5173\u7cfb\uff0c\u5143\u7d20\u4ee5\u952e\u503c\u5bf9\u5b58\u50a8\u3002\u91cd\u8981\u5b9e\u73b0\u7c7b HashMap\u3002<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u952e\u503c\u5bf9\u4ee5 Entry \u5bf9\u8c61\u5b9e\u4f8b\u5b58\u5728\u3002<\/section>\n<\/li>\n<li>\n<section>Key \u4e0d\u53ef\u91cd\u590d\uff0cvalue \u53ef\u4ee5\uff0c\u5373\u591a\u5bf9\u4e00\u3002<\/section>\n<\/li>\n<li>\n<section>\u53ef\u5206\u522b\u8fd4\u56de Key \u96c6\u5408\u3001value \u96c6\u5408\u3001Entry \u96c6\u5408\u3002<\/section>\n<\/li>\n<li>\n<section>\u652f\u6301\u6cdb\u578b\uff1bKey \u548c value \u90fd\u53ef\u4ee5\u4e3a null\u3002<\/section>\n<\/li>\n<li>\n<section>HashMap \u7684 Entry \u65e0\u5e8f\uff0c\u548c List \u76f8\u53cd\u3002<\/section>\n<\/li>\n<li>\n<section>\u6709\u4e14\u53ea\u80fd\u6709\u4e00\u4e2a Key \u4e3a null \u7684\u6620\u5c04\uff08key \u4e0d\u80fd\u91cd\u590d\uff09\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">List \u63a5\u53e3<\/strong>\uff1a\u91cd\u8981\u5b9e\u73b0\u7c7b ArrayList\u3002\u5143\u7d20\u6709\u5e8f\u4e14\u53ef\u91cd\u590d\uff1b\u53ef\u7cbe\u786e\u63a7\u5236\u63d2\u5165\u6216\u5220\u9664\u4f4d\u7f6e\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">Comparator<\/strong>\uff1a\u4e34\u65f6\u6bd4\u8f83\u89c4\u5219\uff0c\u5b9e\u73b0\u7c7b\u5fc5\u987b\u5b9e\u73b0 compare()\u3002<strong style=\"color: #4870ac;\"> Comparable<\/strong>\uff1a\u9ed8\u8ba4\u6bd4\u8f83\u89c4\u5219\uff0c\u5b9e\u4f8b\u53ef\u6bd4\u8f83\u5927\u5c0f\u3001\u53ef\u81ea\u7136\u6392\u5e8f\uff0c\u5fc5\u987b\u5b9e\u73b0 compareTo()\u3002<\/p>\n<table style=\"display: table; text-align: left; overflow: auto; border-collapse: collapse; margin: 1.4em auto; max-width: 100%; table-layout: fixed; overflow-wrap: break-word; word-break: break-all;\" width=\"800\">\n<thead>\n<tr>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u63a5\u53e3<\/th>\n<th style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top; text-align: center; font-weight: bold; color: #4870ac; background: #f7f7f7;\">\u7279\u70b9<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Collection<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">List \/ Set \/ Queue \u7684\u6839\uff0c\u5b9a\u4e49\u589e\u5220\u6539\u67e5<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">List<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u6709\u5e8f\u53ef\u91cd\u590d\uff0c\u53ef\u6309\u4f4d\u7f6e\u64cd\u4f5c<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Map<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Entry \u952e\u503c\u5bf9\uff0cKey \u552f\u4e00<\/td>\n<\/tr>\n<tr>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">Comparable \/ Comparator<\/td>\n<td style=\"border: 1px solid #d9dfe4; padding: 9px 12px; font-size: 0.75em; line-height: 22px; vertical-align: top;\">\u81ea\u7136\u6392\u5e8f vs \u4e34\u65f6\u6bd4\u8f83\u5668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e09\u3001Java \u4e2d\u7684 IO \u6d41<\/h2>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u5b57\u8282\u6d41<\/strong>\uff1a\u7528\u5b8c\u4e00\u5b9a\u8981\u5173\u95ed\u3002<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u4e00\u4e2a\u5b57\u8282\u4e00\u4e2a\u5b57\u8282\u7684\u8bfb\u5199\nFileInputStream in = new FileInputStream(\"\u6e90\u6587\u4ef6\");\nFileOutputStream out = new FileOutputStream(\"\u76ee\u6807\u6587\u4ef6\");\n......\nin.close();\nout.close();<\/code><\/pre>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u5229\u7528\u7f13\u51b2\u533a\uff0c\u9ad8\u6548\u7684\u8bfb\u53d6\u5b57\u8282\nBufferedInputStream in = new BufferedInputStream(new FileInputStream(\"\u6e90\u6587\u4ef6\"));\nBufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(\"\u76ee\u6807\u6587\u4ef6\"));\n......\nin.close();\nout.close();<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u5b57\u7b26\u6d41<\/strong>\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">InputStreamReader isr = new InputStreamReader(new FileInputStream(\"\u6e90\u6587\u4ef6\u8def\u5f84\"), \"\u8bbe\u7f6e\u7f16\u7801\");\nOutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\"), \"\u8bbe\u7f6e\u7f16\u7801\");\n......\nosw.close();\nisr.close();<\/code><\/pre>\n<p style=\"margin: 1em 0px;\">\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">FileReader fr = new FileReader(\"\u6e90\u6587\u4ef6\u8def\u5f84\");\nFileWriter fw = new FileWriter(\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\");\n......\nfr.close();\nfw.close();<\/code><\/pre>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u5229\u7528\u7f13\u51b2\u533a\uff0c\u9ad8\u6548\u7684\u8bfb\u53d6\u5b57\u7b26\nBufferedReader br = new BufferedReader(new FileReader(\"\u6e90\u6587\u4ef6\u8def\u5f84\"));\nPrintWriter pw = new PrintWriter(\"\u76ee\u6807\u6587\u4ef6\u8def\u5f84\");\n......\nbr.close();\npw.close();<\/code><\/pre>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u5e8f\u5217\u5316\u548c\u53cd\u5e8f\u5217\u5316<\/strong>\u3002\u8fd9\u91cc\u7684 file \u6307 <code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">String file = \"\u6587\u4ef6\u5728\u9879\u76ee\u4e2d\u7684\u8def\u5f84\";<\/code>\uff1a<\/p>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u5bf9\u8c61\u7684\u5e8f\u5217\u5316\nObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file));<\/code><\/pre>\n<pre style=\"overflow: auto hidden; word-break: normal; white-space: pre; tab-size: 2; border-radius: 5px; line-height: 2; margin: 1em 0.5em; padding: 0.5em; box-shadow: rgba(0, 0, 0, 0.55) 0px 1px 5px; font-size: 12px; background: #002b36; max-width: 100%; overflow-wrap: normal;\"><code class=\"hljs\" style=\"word-break: normal; white-space: nowrap; tab-size: 2; font-size: 12px; font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; display: block; overflow-x: auto; margin: 0.5em; padding: 3px 5px; color: #93a1a1; background: #002b36; overflow-wrap: normal;\">\/\/ \u5bf9\u8c61\u7684\u53cd\u5e8f\u5217\u5316\nObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));<\/code><\/pre>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u56db\u3001Java \u7684 Socket \u901a\u4fe1\uff08\u591a\u7ebf\u7a0b\uff09<\/h2>\n<p style=\"margin: 1em 0px;\"><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<p style=\"margin: 1em 0px;\">\u601d\u8def\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u521b\u5efa\u670d\u52a1\u5668\u7aef Socket\uff0c\u6307\u5b9a\u5e76\u4fa6\u542c\u67d0\u4e00\u7aef\u53e3\uff0c\u5faa\u73af\u7b49\u5f85\u5ba2\u6237\u7aef\u8fde\u63a5\u3002<\/section>\n<\/li>\n<li>\n<section>\u521b\u5efa\u5ba2\u6237\u7aef Socket\uff0c\u6307\u5b9a\u670d\u52a1\u5668\u5730\u5740\u548c\u7aef\u53e3\uff0c\u83b7\u53d6\u8f93\u51fa\u6d41\u5411\u670d\u52a1\u5668\u53d1\u8bf7\u6c42\uff0c\u5173\u95ed socket \u8f93\u51fa\u6d41\u3002<\/section>\n<\/li>\n<li>\n<section>\u670d\u52a1\u7aef\u6536\u5230\u8bf7\u6c42\u540e\uff0c\u521b\u5efa\u65b0\u7ebf\u7a0b\u5e76\u542f\u52a8\u3002<\/section>\n<\/li>\n<li>\n<section>\u7ebf\u7a0b\u5904\u7406\u7c7b\u83b7\u53d6\u8f93\u5165\u6d41\uff0c\u8bfb\u53d6\u5ba2\u6237\u7aef\u8be6\u60c5\uff0c\u5173\u95ed\u8d44\u6e90\u3002<\/section>\n<\/li>\n<li>\n<section>\u83b7\u53d6\u8f93\u51fa\u6d41\u54cd\u5e94\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u6536\u5230\u54cd\u5e94\u540e\u5173\u95ed\u8d44\u6e90\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\">\u7b80\u5355\u8bb2\uff1a\u6211\u8ddf\u4f60\u8bf4\u8bdd\uff08\u5ba2\u6237\u7aef\u2192\u670d\u52a1\u7aef\uff09\uff0c\u4f60\u6536\u5230\u540e\u4ea4\u7ed9\u5927\u8111\u601d\u8003\uff08\u7ebf\u7a0b\u5904\u7406\u7c7b\uff09\uff0c\u518d\u56de\u7b54\u6211\uff08\u7ebf\u7a0b\u5904\u7406\u7c7b\u2192\u5ba2\u6237\u7aef\uff09\u3002<\/p>\n<h2 style=\"padding: 1px 12.5px; color: #ffffff; margin: 1.2em 0px 1em; border-radius: 4px; display: inline-block; background-color: #4870ac; font-size: 1.3em;\">\u4e94\u3001\u5173\u7cfb\u578b\u6570\u636e\u5e93<\/h2>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e09\u8303\u5f0f<\/strong>\uff1a\u2460 \u5b57\u6bb5\u4e0d\u53ef\u5206\u3002\u2461 \u6709\u4e3b\u952e\uff0c\u975e\u4e3b\u952e\u5b57\u6bb5\u4f9d\u8d56\u4e3b\u952e\u3002\u2462 \u975e\u4e3b\u952e\u5b57\u6bb5\u4e0d\u80fd\u4e92\u76f8\u4f9d\u8d56\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">T-SQL<\/strong>\uff1a\u6574\u4e2a\u5e93\u91cc\u67e5\u8be2\u7ea6\u5360\u589e\u5220\u6539\u67e5\u7684 80%\uff0c\u67e5\u8be2\u79bb\u4e0d\u5f00 T-SQL\u3002<\/p>\n<p style=\"margin: 1em 0px;\"><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<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u589e<\/strong>\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u63d2\u5165\u5355\u884c\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">insert into &lt;\u8868\u540d&gt; (\u5217\u540d) values (\u5217\u503c)<\/code><\/section>\n<\/li>\n<li>\n<section>\u73b0\u6709\u8868\u6570\u636e\u52a0\u5230\u5df2\u6709\u8868\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">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><\/section>\n<\/li>\n<li>\n<section>\u62ff\u73b0\u6709\u8868\u6570\u636e\u5efa\u65b0\u8868\u5e76\u586b\u5145\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">select &lt;\u65b0\u5efa\u8868\u5217\u540d&gt; into &lt;\u65b0\u5efa\u8868\u540d&gt; from &lt;\u6e90\u8868\u540d&gt;<\/code><\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u5220<\/strong>\uff1a<\/p>\n<ul style=\"padding-left: 1rem; margin-left: 1rem; font-size: 0.9rem; list-style-type: disc;\">\n<li>\n<section>\u5220\u9664\u6ee1\u8db3\u6761\u4ef6\u7684\u884c\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">delete from &lt;\u8868\u540d&gt; where &lt;\u5220\u9664\u6761\u4ef6&gt;<\/code><\/section>\n<\/li>\n<li>\n<section>\u5220\u9664\u6574\u4e2a\u8868\u6570\u636e\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">truncate table &lt;\u8868\u540d&gt;<\/code>\u3002\u5220\u9664\u6240\u6709\u884c\uff0c\u4f46\u7ed3\u6784\u3001\u5217\u3001\u7ea6\u675f\u3001\u7d22\u5f15\u4e0d\u4f1a\u88ab\u5220\uff1b\u4e0d\u80fd\u7528\u4e8e\u6709\u5916\u952e\u7ea6\u675f\u5f15\u7528\u7684\u8868\u3002<\/section>\n<\/li>\n<\/ul>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u6539<\/strong>\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">update &lt;\u8868\u540d&gt; set &lt;\u5217\u540d=\u66f4\u65b0\u503c&gt; where &lt;\u66f4\u65b0\u6761\u4ef6&gt;<\/code><\/p>\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u5b50\u67e5\u8be2<\/strong>\uff1a<code style=\"font-family: Menlo, Monaco, Consolas, 'Liberation Mono', 'Roboto Mono', 'Courier New', 'Microsoft YaHei', monospace; color: #4870ac; font-size: 0.9em; font-weight: normal; overflow-wrap: break-word; padding: 2px 4px; border-radius: 3px; margin: 2px; background-color: #f6f8fa; word-break: break-all;\">SELECT * FROM t1 WHERE column1 = (SELECT column1 FROM t2);<\/code> \u5916\u5c42\u662f\u5916\u67e5\u8be2\uff0c\u62ec\u53f7\u5185\u662f\u5b50\u67e5\u8be2\uff0c\u5fc5\u987b\u51fa\u73b0\u5728\u5706\u62ec\u53f7\u4e4b\u95f4\uff0c\u8fd8\u53ef\u4ee5\u518d\u5d4c\u5957\u3002<\/p>\n<p style=\"margin: 1em 0px;\">\u8f6c\u81f3\uff1ahttp:\/\/www.jianshu.com\/p\/e4ba72acffa9#<\/p>\n<blockquote style=\"display: block; font-size: 0.9em; border-left: 3px solid #4870ac; padding: 0.5em 1em; margin: 0px; background: #f6f8fa; color: #40464f;\">\n<p style=\"margin: 1em 0px;\"><strong style=\"color: #4870ac;\">\u4e00\u53e5\u8bdd\u603b\u7ed3\uff1a\u9762\u8bd5\u57fa\u7840\u7bc7\u5148\u628a\u7ee7\u627f\u5c01\u88c5\u591a\u6001\u8bb2\u6e05\u695a\uff0c\u518d\u987a\u7740\u96c6\u5408\u6811\u3001IO \u5f00\u5173\u6d41\u3001Socket \u4e00\u8bf7\u6c42\u4e00\u7ebf\u7a0b\u3001SQL \u4e09\u8303\u5f0f\u548c\u589e\u5220\u6539\u67e5\u628a\u52a8\u624b\u80fd\u529b\u6446\u51fa\u6765\u3002<\/strong><\/p>\n<\/blockquote>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<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\u8e0f\u4e0a\u8fd9\u6761\u201c\u70e7\u8111\u201d\u8def\uff1b\u4e5f\u6709\u4eba\u56e0\u4e3a\u68a6\u60f3\u548c\u6267\u7740\uff1b\u8fd8\u6709\u4eba\u88ab\u73b0\u5b9e [&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":[43,171,140],"_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":3,"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}]}}