Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: plugins/CsBeagle/GameTigerIpProvider.java


1   /*
2    * GameTigerIpProvider.java
3    *
4    * Created on November 3, 2002, 12:47 AM
5    */
6   
7   package plugins.CsBeagle;
8   
9   import java.net.*;
10  import java.io.*;
11  /**
12   *
13   * @author  Tobias Riemer
14   */
15  public class GameTigerIpProvider {
16  
17      private String ip = new String();
18      /** Creates a new instance of GameTigerIpProvider */
19      public GameTigerIpProvider() {
20      }
21      
22      public void sendIp() throws UnknownHostException, IOException {
23          Socket socket = new Socket("127.0.0.1", 4444);
24          PrintWriter out = new PrintWriter(socket.getOutputStream(), true);
25          //in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
26          out.println(ip);
27          out.close();
28          //in.close();
29          socket.close();
30      }
31      
32      public void loadFile(String fname) throws FileNotFoundException, IOException {
33          BufferedReader rf = new BufferedReader(new FileReader(fname));
34                  
35          String line = null;
36          while ((line = rf.readLine()) != null) {                        
37              if (line.startsWith("address")) {
38                  int i = line.indexOf('=');
39                  if (i != -1) ip = line.substring(i+1);
40              }
41          }        
42          rf.close();        
43      }
44      
45      /**
46       * @param args the command line arguments
47       */
48      public static void main(String[] args) {
49          
50          if (args.length > 0) {
51              System.out.println(args[0]);
52              GameTigerIpProvider gip = new GameTigerIpProvider();
53              try {
54                  gip.loadFile(args[0]);
55                  gip.sendIp();
56              } catch (Exception ex) {
57                  ex.printStackTrace();
58              }
59          }
60      }
61      
62  }