1
mirror of https://github.com/Shiewk/SModeration.git synced 2026-04-28 05:54:16 +02:00

Add gzip-compressed saving and loading system

This commit is contained in:
Shy
2024-06-09 10:55:32 +02:00
parent deee125e88
commit 9e59bae857
5 changed files with 137 additions and 15 deletions
@@ -42,4 +42,19 @@ public abstract class ByteUtil {
long m = bytesToLong(new byte[]{ i[0], i[1], i[2], i[3], i[4], i[5], i[6], i[7] });
return new UUID(m, l);
}
public static int bytesToInt(byte[] bytes) {
if (bytes.length != 4){
throw new IllegalArgumentException("length must be 4");
}
ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.put(0, bytes);
return buffer.getInt(0);
}
public static byte[] intToBytes(int value) {
ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.putInt(value);
return buffer.array();
}
}