示例#1
0
文件: Main.java 项目: KeplerFL/Java
 public static void console() {
   String st = b.getText();
   b.setText(null);
   arr = st.split("\\ ");
   if (arr[0].contains("he")) {
     help();
   } else if (arr[0].equalsIgnoreCase("system")) {
     if (arr[1].equalsIgnoreCase("shutdown")) {
       if (arr.length == 2) System.exit(1);
       else if (arr[2].equalsIgnoreCase("cancel")) {
         run.ok = false;
         debug("Shutdown cancelled");
       } else {
         t = new Thread(new run(Integer.parseInt(arr[2])));
         t.start();
         debug("shutdown started. Server will stop in " + arr[2] + "  seconds");
       }
     } else if (arr[1].contains("top")) {
       if (arr[2].equalsIgnoreCase("TRUE")
           || arr[2].equalsIgnoreCase("ON")
           || arr[2].equalsIgnoreCase("1")) {
         f.setAlwaysOnTop(true);
         debug("Frame always on top");
       } else if (arr[2].equalsIgnoreCase("FALSE")
           || arr[2].equalsIgnoreCase("OFF")
           || arr[2].equalsIgnoreCase("0")) {
         f.setAlwaysOnTop(false);
         debug("Frame no longer always on top");
       } else help();
     } else if (arr[0].equalsIgnoreCase("kick")) {
       Iterator i = s.clients.iterator();
       while (i.hasNext()) {
         Socket s = (Socket) i.next();
         if (arr[1].equalsIgnoreCase(s.getInetAddress().toString())) {
           try {
             s.getInputStream().close();
             s.getOutputStream().close();
             s.close();
           } catch (IOException e) {
           }
         }
       }
     } else help();
   } else if (arr[0].equalsIgnoreCase("broad")
       || arr[0].equalsIgnoreCase("bcast")
       || arr[0].equalsIgnoreCase("broadcast")) s.broadcastMessage(arr[1]);
   else if (arr[0].equalsIgnoreCase("list")) {
     if (arr[1].equalsIgnoreCase("client")) {
       s.ListClients();
     }
   } else help();
 }