{"id":2914,"date":"2018-06-30T19:21:47","date_gmt":"2018-06-30T11:21:47","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2914"},"modified":"2018-06-30T19:21:47","modified_gmt":"2018-06-30T11:21:47","slug":"java-runtime-%e7%b1%bb-api-%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2914","title":{"rendered":"Java Runtime \u7c7b API \u5927\u5168"},"content":{"rendered":"<p>\n\tJava \u4e2d\u7684 Runtime \u7c7b\uff0c\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u63a5\u89e6\u7684\u90fd\u4e0d\u591a\u3002\u56e0\u4e3a\u5927\u90e8\u5206\u7a0b\u5e8f\u5458\u90fd\u662f\u4e1a\u52a1\u578b\u7684\uff0c\u5bf9\u4e8e\u4e00\u4e9b\u7279\u6b8a\u529f\u80fd\u4f7f\u7528\u7684\u5c11\u4e4b\u53c8\u5c11\uff0c\u53ef\u80fd\u5bf9&nbsp;Java Runtime \u7c7b\u5c31\u4e0d\u592a\u719f\u6089\u3002\n<\/p>\n<p>\n\t\u6700\u8fd1\u4e24\u5929\u53c8\u6709\u7f51\u53cb\u7ed9\u6211\u5728&ldquo;\u4e1a\u4f59\u8349&rdquo;\u5fae\u4fe1\u516c\u4f17\u53f7\u91cc\u7559\u8a00\uff0c\u95ee\u9898\u5bf9 Runtime \u7c7b\u719f\u6089\u4e0d\uff0c\u6211\u8fd9\u8fb9\u7d22\u6027\u4e00\u6b21\u6027\u628a Runtime \u7c7b\u76f8\u5173\u7684 API \u5168\u90e8\u6574\u7406\u51fa\u6765\uff0c\u5927\u5bb6\u5171\u52c9\uff0c\u4e92\u76f8\u5b66\u4e60\uff01\n<\/p>\n<p>\n\t\u9996\u5148\u8bf4\u8bf4\u8fd9\u4e2a\u795e\u5947\u7684 Runtime \u7c7b,\u4e3b\u8981\u5c01\u88c5\u4e86 Java \u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\uff0c\u6bcf\u4e00\u4e2a Java \u7a0b\u5e8f\u90fd\u6709\u4e00\u4e2a\u4e0e\u4e4b\u5bf9\u5e94\u7684 Runtime \u5b9e\u4f8b\uff0c\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7\u8be5\u5bf9\u8c61\u4e0e\u8fd0\u884c\u65f6\u73af\u5883\u76f8\u8fde\uff0c\u5e94\u7528\u7a0b\u5e8f\u4e0d\u80fd\u521b\u5efa\u81ea\u5df1\u7684 Runtime \u5b9e\u4f8b\uff0c\u4f46\u53ef\u4ee5\u901a\u8fc7 getRuntime() \u65b9\u6cd5\u83b7\u5f97\u4e0e\u4e4b\u5173\u8054\u7684 Runtime \u5bf9\u8c61\u3002\n<\/p>\n<p>\n\tRuntime \u4ee3\u8868 Java \u7a0b\u5e8f\u7684\u8fd0\u884c\u65f6\u73af\u5883\uff0c\u53ef\u4ee5\u8bbf\u95ee JVM \u7684\u76f8\u5173\u4fe1\u606f\uff0c\u5982\u5904\u7406\u5668\u6570\u91cf\uff0c\u5185\u5b58\u4fe1\u606f\u3002\n<\/p>\n<h2>\n\tRuntime<br \/>\n<\/h2>\n<ul>\n<li>\n\t\taddShutdownHook(Thread hook)&nbsp;\u6ce8\u518c\u65b0\u7684\u865a\u62df\u673a\u6765\u5173\u95ed\u6302\u94a9\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tavailableProcessors()&nbsp;&nbsp;\u5411 Java \u865a\u62df\u673a\u8fd4\u56de\u53ef\u7528\u5904\u7406\u5668\u7684\u6570\u76ee\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String command)&nbsp;&nbsp;\u5728\u5355\u72ec\u7684\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u547d\u4ee4\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String[] cmdarray)&nbsp; \u5728\u5355\u72ec\u7684\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u547d\u4ee4\u548c\u53d8\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String[] cmdarray, String[] envp)&nbsp;&nbsp;\u5728\u6307\u5b9a\u73af\u5883\u7684\u72ec\u7acb\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u547d\u4ee4\u548c\u53d8\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String[] cmdarray, String[] envp, File dir)&nbsp;&nbsp;\u5728\u6307\u5b9a\u73af\u5883\u548c\u5de5\u4f5c\u76ee\u5f55\u7684\u72ec\u7acb\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u7684\u547d\u4ee4\u548c\u53d8\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String command, String[] envp)&nbsp;&nbsp;\u5728\u6307\u5b9a\u73af\u5883\u7684\u5355\u72ec\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u547d\u4ee4\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texec(String command, String[] envp, File dir)&nbsp;&nbsp;\u5728\u6709\u6307\u5b9a\u73af\u5883\u548c\u5de5\u4f5c\u76ee\u5f55\u7684\u72ec\u7acb\u8fdb\u7a0b\u4e2d\u6267\u884c\u6307\u5b9a\u7684\u5b57\u7b26\u4e32\u547d\u4ee4\u3002&nbsp;\n\t<\/li>\n<li>\n\t\texit(int status)&nbsp;&nbsp;\u901a\u8fc7\u542f\u52a8\u865a\u62df\u673a\u7684\u5173\u95ed\u5e8f\u5217\uff0c\u7ec8\u6b62\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684 Java \u865a\u62df\u673a\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tfreeMemory()&nbsp;&nbsp;\u8fd4\u56de Java \u865a\u62df\u673a\u4e2d\u7684\u7a7a\u95f2\u5185\u5b58\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tgc()&nbsp;&nbsp;\u8fd0\u884c\u5783\u573e\u56de\u6536\u5668\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tInputStream getLocalizedInputStream(InputStream in)&nbsp;\u5df2\u8fc7\u65f6\u3002 \u4ece JDK 1.1 \u5f00\u59cb\uff0c\u5c06\u672c\u5730\u7f16\u7801\u5b57\u8282\u6d41\u8f6c\u6362\u4e3a Unicode \u5b57\u7b26\u6d41\u7684\u9996\u9009\u65b9\u6cd5\u662f\u4f7f\u7528 InputStreamReader \u548c BufferedReader \u7c7b\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tOutputStream getLocalizedOutputStream(OutputStream out)&nbsp;&nbsp;\u5df2\u8fc7\u65f6\u3002 \u4ece JDK 1.1 \u5f00\u59cb\uff0c\u5c06 Unicode \u5b57\u7b26\u6d41\u8f6c\u6362\u4e3a\u672c\u5730\u7f16\u7801\u5b57\u8282\u6d41\u7684\u9996\u9009\u65b9\u6cd5\u662f\u4f7f\u7528 OutputStreamWriter\u3001BufferedWriter \u548c PrintWriter \u7c7b\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tgetRuntime()&nbsp;&nbsp;\u8fd4\u56de\u4e0e\u5f53\u524d Java \u5e94\u7528\u7a0b\u5e8f\u76f8\u5173\u7684\u8fd0\u884c\u65f6\u5bf9\u8c61\u3002&nbsp;\n\t<\/li>\n<li>\n\t\thalt(int status)&nbsp;&nbsp;\u5f3a\u884c\u7ec8\u6b62\u76ee\u524d\u6b63\u5728\u8fd0\u884c\u7684 Java \u865a\u62df\u673a\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tload(String filename)&nbsp;\u52a0\u8f7d\u4f5c\u4e3a\u52a8\u6001\u5e93\u7684\u6307\u5b9a\u6587\u4ef6\u540d\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tloadLibrary(String libname)&nbsp;&nbsp;\u52a0\u8f7d\u5177\u6709\u6307\u5b9a\u5e93\u540d\u7684\u52a8\u6001\u5e93\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tmaxMemory()&nbsp;&nbsp;\u8fd4\u56de Java \u865a\u62df\u673a\u8bd5\u56fe\u4f7f\u7528\u7684\u6700\u5927\u5185\u5b58\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\tremoveShutdownHook(Thread hook)&nbsp;\u53d6\u6d88\u6ce8\u518c\u67d0\u4e2a\u5148\u524d\u5df2\u6ce8\u518c\u7684\u865a\u62df\u673a\u5173\u95ed\u6302\u94a9\u3002&nbsp;\n\t<\/li>\n<li>\n\t\trunFinalization()&nbsp;&nbsp;\u8fd0\u884c\u6302\u8d77 finalization \u7684\u6240\u6709\u5bf9\u8c61\u7684\u7ec8\u6b62\u65b9\u6cd5\u3002&nbsp;\n\t<\/li>\n<li>\n\t\trunFinalizersOnExit(value)&nbsp;&nbsp;\u5df2\u8fc7\u65f6\u3002 \u6b64\u65b9\u6cd5\u672c\u8eab\u5177\u6709\u4e0d\u5b89\u5168\u6027\u3002\u5b83\u53ef\u80fd\u5bf9\u6b63\u5728\u4f7f\u7528\u7684\u5bf9\u8c61\u8c03\u7528\u7ec8\u7ed3\u65b9\u6cd5\uff0c\u800c\u5176\u4ed6\u7ebf\u7a0b\u6b63\u5728\u64cd\u4f5c\u8fd9\u4e9b\u5bf9\u8c61\uff0c\u4ece\u800c\u5bfc\u81f4\u4e0d\u6b63\u786e\u7684\u884c\u4e3a\u6216\u6b7b\u9501\u3002&nbsp;\n\t<\/li>\n<li>\n\t\ttotalMemory()&nbsp;&nbsp;\u8fd4\u56de Java \u865a\u62df\u673a\u4e2d\u7684\u5185\u5b58\u603b\u91cf\u3002&nbsp;\n\t<\/li>\n<li>\n\t\ttraceInstructions(on)&nbsp;&nbsp;\u542f\u7528\uff0f\u7981\u7528\u6307\u4ee4\u8ddf\u8e2a\u3002&nbsp;\n\t<\/li>\n<li>\n\t\ttraceMethodCalls(on)&nbsp;&nbsp;\u542f\u7528\uff0f\u7981\u7528\u65b9\u6cd5\u8c03\u7528\u8ddf\u8e2a\u3002\n\t<\/li>\n<\/ul>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/baike.baidu.com\/item\/runtime\/4723760\" name=\"runtime\" target=\"_blank\" title=\"runtime\">https:\/\/baike.baidu.com\/item\/runtime\/4723760<\/a>\n\t<\/li>\n<li>\n\t\t<a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/\" name=\"java api docs\" target=\"_blank\" title=\"java api docs\">https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/<\/a>\n\t<\/li>\n<\/ul>\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=2914\">Java Runtime \u7c7b API \u5927\u5168<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>Java \u4e2d\u7684 Runtime \u7c7b\uff0c\u5927\u591a\u6570\u7a0b\u5e8f\u5458\u63a5\u89e6\u7684\u90fd\u4e0d\u591a\u3002\u56e0\u4e3a\u5927\u90e8\u5206\u7a0b\u5e8f\u5458\u90fd\u662f\u4e1a\u52a1\u578b\u7684\uff0c\u5bf9\u4e8e\u4e00\u4e9b\u7279\u6b8a\u529f\u80fd\u4f7f [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1170,69,71,1657,1506],"class_list":["post-2914","post","type-post","status-publish","format-standard","hentry","category-java","tag-inputstream","tag-java","tag-outputstream","tag-runtime","tag-unicode"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2914","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=2914"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2914\/revisions"}],"predecessor-version":[{"id":2915,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2914\/revisions\/2915"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}