9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 03:29:06 +00:00

Smoothiemaps & nbt

This commit is contained in:
Daniel Mills
2020-12-28 06:10:41 -05:00
parent cec56c8406
commit 4f3b6e4029
45 changed files with 4328 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package net.querz.io;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public interface Serializer<T> {
void toStream(T object, OutputStream out) throws IOException;
default void toFile(T object, File file) throws IOException {
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
toStream(object, bos);
}
}
default byte[] toBytes(T object) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
toStream(object, bos);
bos.close();
return bos.toByteArray();
}
}