Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. public class UUIDUtils {
  2.  
  3. public static String compress(UUID uuid) {
  4. ByteBuffer bb = ByteBuffer.allocate(Long.BYTES * 2);
  5. bb.putLong(uuid.getMostSignificantBits());
  6. bb.putLong(uuid.getLeastSignificantBits());
  7. byte[] array = bb.array();
  8. return Base64.getEncoder().encodeToString(array);
  9. }
  10.  
  11. public static UUID decompress(String compressUUID) {
  12. ByteBuffer byteBuffer = ByteBuffer.wrap(Base64.getDecoder().decode(compressUUID));
  13. return new UUID(byteBuffer.getLong(), byteBuffer.getLong());
  14. }
  15.  
  16.  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement