62,614
社区成员
发帖
与我相关
我的任务
分享
// The default daytime port
static int DAYTIME_PORT = 13;
// The port we'll actually use
static int port = DAYTIME_PORT;
try {
address = new InetSocketAddress(InetAddress.getByName(host),port);
} catch (IOException x) {
failure = x;
}
public static void main( String[] args )
{
StringBuffer buf = new StringBuffer();
String s = "";
Process process;
try
{
process = Runtime.getRuntime().exec( "cmd /c " + "ping 127.0.0.1" );
BufferedReader br = new BufferedReader( new InputStreamReader(
process.getInputStream() ) );
while ( ( s = br.readLine() ) != null )
{
buf.append( s + "\r\n" );
}
process.waitFor();
System.out.println( buf );
} catch ( Exception ex )
{
ex.printStackTrace();
}
}