📄 client.java
字号:
/*
* client.java
*
* Created on 11 novembre 2008, 19:54
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package clientDT;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;
/**
*
* @author Administrateur
*/
public class client {
/** Creates a new instance of client */
public client() {
}
public static void main(String agrs[]) throws UnknownHostException
{
InetAddress address = InetAddress.getLocalHost();
String hote=address.getHostName();
try
{
Socket S = new Socket(hote,13) ;
InputStream is = S.getInputStream();
StringBuffer sb=new StringBuffer();
//OutputStream os= new OutputStream();
int c ;
while((c=is.read())!=-1) sb.append((char)c);
String dh=sb.toString().trim();
System.out.println("la date et l'heure de la machine distant " +hote+" est :"+dh);
}
catch(UnknownHostException e)
{
System.out.println(e.getMessage());
}
catch(IOException e)
{
System.out.println(e.getMessage());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -