Advertisement
TriiNoxYs

ServerInfos

Aug 27th, 2015
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public static String[] getServerInfos(String ip, int port){
  2.         try{
  3.             Socket socket = new Socket();
  4.             socket.connect(new InetSocketAddress(ip, port), 1 * 1000);
  5.             DataOutputStream out = new DataOutputStream(socket.getOutputStream());
  6.             DataInputStream in = new DataInputStream(socket.getInputStream());
  7.             out.write(0xFE);
  8.             StringBuilder str = new StringBuilder();
  9.             int b;
  10.             while((b = in.read()) != -1){
  11.                 if(b != 0 && b > 16 && b != 255 && b != 23 && b != 24){
  12.                     str.append((char) b);
  13.                 }
  14.             }
  15.             String[] data = str.toString().split("§");
  16.                
  17.             socket.close();
  18.             return data;
  19.                
  20.         }catch(Exception e){
  21.             e.printStackTrace();
  22.         }
  23.         return null;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement