Guest User

ReadIn.class

a guest
Jan 27th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.io.PrintStream;
  5. import java.net.Socket;
  6.  
  7. public class ReadIn
  8.   extends Thread
  9. {
  10.   public String last = "";
  11.   public String part1 = "";
  12.   public String part3 = "";
  13.   private BufferedReader in;
  14.  
  15.   public ReadIn(Socket socket)
  16.   {
  17.     try
  18.     {
  19.       this.in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  20.     }
  21.     catch (IOException e)
  22.     {
  23.       e.printStackTrace();
  24.     }
  25.   }
  26.  
  27.   public void run()
  28.   {
  29.     try
  30.     {
  31.       for (;;)
  32.       {
  33.         this.last = this.in.readLine();
  34.         if ((this.last != null) &&
  35.           (this.last.contains("miner-notify")))
  36.         {
  37.           System.out.println(this.last);
  38.           this.part1 = this.last.substring(this.last.indexOf("part1\":") + 8, this.last.indexOf("payload_start") - 3);
  39.           this.part3 = this.last.substring(this.last.indexOf("part3\":") + 8, this.last.indexOf("target") - 3);
  40.           System.out.println("Part1: " + this.part1);
  41.           System.out.println("Part3: " + this.part3);
  42.         }
  43.       }
  44.     }
  45.     catch (IOException e)
  46.     {
  47.       e.printStackTrace();
  48.     }
  49.   }
  50. }
Add Comment
Please, Sign In to add comment