import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.ServerSocket
import java.net.Socket
import java.util.Date
public class RunUserCenterSystem {
public static void main(String[] args) {
try {
ServerSocket ss = new ServerSocket(51818)
while (true) {
Socket socket = ss.accept()
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()))
String line = in.readLine()
if("stop".trim().equalsIgnoreCase(line)){
if(ctx != null){
ctx.stop()
ctx.close()
System.exit(0)
}
}else{
System.out.println("接收的数据为: "+line)
}
in.close()
socket.close()
}
} catch (Exception e) {
}
}
}
使用如下命令实现网络断开 *** 作ipconfig /release
public static void main(String[] args) {
try {
//通过process方式发起windows命令行命令执行
String cmd = "ipconfig /release"
Process p = Runtime.getRuntime().exec(cmd)
p.waitFor()
} catch (Exception e) {
e.printStackTrace()
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)