Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.49 KB | None | 0 0
  1. import java.nio.ByteBuffer;
  2.  
  3. class BBTest
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         ByteBuffer bb1 = ByteBuffer.wrap("foobar".getBytes());
  8.         ByteBuffer bb2 = ByteBuffer.wrap("bar".getBytes());
  9.         bb1.get(new byte[3]);
  10.  
  11.         assert bb1.remaining() == bb2.remaining();
  12.         for (int i = 0; i < bb1.remaining(); ++i)
  13.         {
  14.             assert bb1.get(bb1.position() + i) == bb2.get(bb2.position() + i);
  15.         }
  16.  
  17.         assert bb1 == bb2;
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement