📄 sockettest.java
字号:
/**
@version 1.10 1997-06-27
@author Cay Horstmann
*/
import java.io.*;
import java.net.*;
/**
This program makes a socket connection to the atomic clock
in Boulder, Colorado, and prints the time that the
server sends.
*/
public class SocketTest
{
public static void main(String[] args)
{
try
{
Socket s = new Socket("time-A.timefreq.bldrdoc.gov",
13);
BufferedReader in = new BufferedReader
(new InputStreamReader(s.getInputStream()));
boolean more = true;
while (more)
{
String line = in.readLine();
if (line == null)
more = false;
else
System.out.println(line);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -