runtime.html

来自「j2se5-api-zh,java文档的中文版本」· HTML 代码 · 共 944 行 · 第 1/4 页

HTML
944
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_03) on Wed Nov 02 09:48:34 CST 2005 --><META http-equiv="Content-Type" content="text/html; charset=gb2312"><TITLE>Runtime (Java 2 Platform SE 5.0)</TITLE><META NAME="keywords" CONTENT="java.lang.Runtime class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="Runtime (Java 2 Platform SE 5.0)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="跳过导航链接"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>概述</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>软件包</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>类</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/Runtime.html"><FONT CLASS="NavBarFont1"><B>使用</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>树</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>已过时</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>索引</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>帮助</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Standard&nbsp;Ed. 5.0</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="Runnable.html" title="java.lang 中的接口"><B>上一个类</B></A>&nbsp;&nbsp;<A HREF="RuntimeException.html" title="java.lang 中的类"><B>下一个类</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../index.html@java_2Flang_2FRuntime.html" target="_top"><B>框架</B></A>  &nbsp;&nbsp;<A HREF="Runtime.html" target="_top"><B>无框架</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../allclasses-noframe.html"><B>所有类</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../allclasses-noframe.html"><B>所有类</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  摘要:&nbsp;嵌套&nbsp;|&nbsp;字段&nbsp;|&nbsp;构造方法&nbsp;|&nbsp;<A HREF="#method_summary">方法</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">详细信息:&nbsp;字段&nbsp;|&nbsp;构造方法&nbsp;|&nbsp;<A HREF="#method_detail">方法</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">java.lang</FONT><BR>类 Runtime</H2><PRE><A HREF="Object.html" title="java.lang 中的类">java.lang.Object</A>  <IMG SRC="../../resources/inherit.gif" ALT="继承者 "><B>java.lang.Runtime</B></PRE><HR><DL><DT><PRE>public class <B>Runtime</B><DT>extends <A HREF="Object.html" title="java.lang 中的类">Object</A></DL></PRE><P>每个 Java 应用程序都有一个 <code>Runtime</code> 类实例,使应用程序能够与其运行的环境相连接。可以通过 <code>getRuntime</code> 方法获取当前运行时。  <p>应用程序不能创建自己的 Runtime 类实例。<P><P><DL><DT><B>从以下版本开始:</B></DT>  <DD>JDK1.0</DD><DT><B>另请参见:</B><DD><A HREF="Runtime.html#getRuntime()"><CODE>getRuntime()</CODE></A></DL><HR><P><!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>方法摘要</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#addShutdownHook(java.lang.Thread)">addShutdownHook</A></B>(<A HREF="Thread.html" title="java.lang 中的类">Thread</A>&nbsp;hook)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;注册新的虚拟机来关闭挂钩。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;int</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#availableProcessors()">availableProcessors</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;向 Java 虚拟机返回可用处理器的数目。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String)">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;command)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在单独的进程中执行指定的字符串命令。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String[])">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;cmdarray)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在单独的进程中执行指定命令和变量。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String[], java.lang.String[])">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;cmdarray,     <A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;envp)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在指定环境的独立进程中执行指定命令和变量。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String[], java.lang.String[], java.io.File)">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;cmdarray,     <A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;envp,     java.io.File&nbsp;dir)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在指定环境和工作目录的独立进程中执行指定的命令和变量。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String, java.lang.String[])">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;command,     <A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;envp)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在指定环境的单独进程中执行指定的字符串命令。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="Process.html" title="java.lang 中的类">Process</A></CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exec(java.lang.String, java.lang.String[], java.io.File)">exec</A></B>(<A HREF="String.html" title="java.lang 中的类">String</A>&nbsp;command,     <A HREF="String.html" title="java.lang 中的类">String</A>[]&nbsp;envp,     java.io.File&nbsp;dir)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;在有指定环境和工作目录的独立进程中执行指定的字符串命令。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#exit(int)">exit</A></B>(int&nbsp;status)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;通过启动虚拟机的关闭序列,终止当前正在运行的 Java 虚拟机。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;long</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#freeMemory()">freeMemory</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回 Java 虚拟机中的空闲内存量。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#gc()">gc</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;运行垃圾回收器。</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.io.InputStream</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#getLocalizedInputStream(java.io.InputStream)">getLocalizedInputStream</A></B>(java.io.InputStream&nbsp;in)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>已过时。</B>&nbsp;<I>从 JDK&nbsp;1.1 开始,将本地编码字节流转换为 Unicode 字符流的首选方法是使用 <code>InputStreamReader</code> 和 <code>BufferedReader</code> 类。</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;java.io.OutputStream</CODE></FONT></TD><TD><CODE><B><A HREF="Runtime.html#getLocalizedOutputStream(java.io.OutputStream)">getLocalizedOutputStream</A></B>(java.io.OutputStream&nbsp;out)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B>已过时。</B>&nbsp;<I>从 JDK&nbsp;1.1 开始,将 Unicode 字符流转换为本地编码字节流的首选方法是使用 <code>OutputStreamWriter</code>、<code>BufferedWriter</code> 和 <code>PrintWriter</code> 类。</I></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="Runtime.html" title="java.lang 中的类">Runtime</A></CODE></FONT></TD>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?