sarkanydavidhu

Java

Apr 16th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1.  public Answer(InputStream input)
  2.   {
  3.     byte[] bytes = new byte[getDataLength()];
  4.     try
  5.     {
  6.       if (input.read(bytes, 0, getDataLength()) != getDataLength()) {
  7.         throw new InterruptedException();
  8.       }
  9.     }
  10.     catch (IOException e)
  11.     {
  12.       e.printStackTrace();
  13.     }
  14.     catch (InterruptedException e)
  15.     {
  16.       e.printStackTrace();
  17.     }
  18.     ByteBuffer byteBuffer = ByteBuffer.allocate(getDataLength());
  19.     byteBuffer.put(bytes);
  20.     byteBuffer.rewind();
  21.     this.myShootResult = ShootResult.fromInt(byteBuffer.getInt());
  22.     this.enemyShootResult = ShootResult.fromInt(byteBuffer.getInt());
  23.     this.enemyShootX = byteBuffer.getInt();
  24.     this.enemyShootY = byteBuffer.getInt();
  25.     this.moveSuccessCount = byteBuffer.getInt();
  26.     this.newShipCount = byteBuffer.getInt();
  27.     this.fieldHeight = byteBuffer.getInt();
  28.     this.fieldWidth = byteBuffer.getInt();
  29.   }
Advertisement
Add Comment
Please, Sign In to add comment