diff --git a/README.md b/README.md index 7e95c42..0b25b2a 100644 --- a/README.md +++ b/README.md @@ -50,5 +50,6 @@ dependencies{ - [utils](utils%2FREADME.md) - [entries](utils%2FREADME.md#entries) `utils-entries` - [files](utils%2FREADME.md#files) `utils-files` + - [io](utils%2FREADME.md#io) `utils-io` - [pools](utils%2FREADME.md#pools) `utils-pools` - [refs](utils%2FREADME.md#refs) `utils-refs` \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 42c3323..6b24d41 100644 --- a/settings.gradle +++ b/settings.gradle @@ -15,6 +15,7 @@ include ":utils:files" include ":utils:pools" include ":utils:entries" include ":utils:refs" +include ":utils:io" include "settings" include "betterCommandHandler" diff --git a/utils/README.md b/utils/README.md index ffb1d1e..c5f7b1e 100644 --- a/utils/README.md +++ b/utils/README.md @@ -2,6 +2,7 @@ - [Entries](#entries) - [Files](#files) +- [IO](#io) - [Pools](#pools) - [Refs](#refs) @@ -22,6 +23,16 @@ Adds `set`, `create` and `copy` methods for each exited Entry type in `Arc` Adds [`arclibrary.utils.files.InternalFileTree`](files%2Fsrc%2Farclibrary%2Futils%2Ffiles%2FInternalFileTree.java) for internal jar navigation. --- +## UI + +###### Full name: `utils-ui` + +### Adds +- [ByteReads](io%2Fsrc%2Farclibrary%2Fio%2FByteReads.java) +- [ByteWrites](io%2Fsrc%2Farclibrary%2Fio%2FByteWrites.java) + +---- + # Pools ###### Full name: `utils-pools` diff --git a/utils/entries/build.gradle b/utils/entries/build.gradle deleted file mode 100644 index cd8dfae..0000000 --- a/utils/entries/build.gradle +++ /dev/null @@ -1,3 +0,0 @@ -dependencies{ - -} \ No newline at end of file diff --git a/utils/io/src/arclibrary/io/ByteReads.java b/utils/io/src/arclibrary/io/ByteReads.java new file mode 100644 index 0000000..2635e08 --- /dev/null +++ b/utils/io/src/arclibrary/io/ByteReads.java @@ -0,0 +1,37 @@ +package arclibrary.io; + +import arc.util.io.*; + +import java.io.*; +/** + * Uses to read something from clear bytes + * */ +public class ByteReads extends Reads{ + public final ReusableByteInStream r = new ReusableByteInStream(); + + public ByteReads(){ + super(null); + input = new DataInputStream(r); + } + + public ByteReads(byte[] bytes){ + this(); + setBytes(bytes); + } + + public static ReusableByteInStream setBytes(Reads reads, byte[] bytes){ + if(reads instanceof ByteReads){ + ByteReads byteReads = (ByteReads)reads; + byteReads.setBytes(bytes); + return byteReads.r; + } + ReusableByteInStream reusableByteInStream = new ReusableByteInStream(); + reads.input = new DataInputStream(reusableByteInStream); + reusableByteInStream.setBytes(bytes); + return reusableByteInStream; + } + + public void setBytes(byte[] bytes){ + r.setBytes(bytes); + } +} diff --git a/utils/io/src/arclibrary/io/ByteWrites.java b/utils/io/src/arclibrary/io/ByteWrites.java new file mode 100644 index 0000000..17b2c34 --- /dev/null +++ b/utils/io/src/arclibrary/io/ByteWrites.java @@ -0,0 +1,24 @@ +package arclibrary.io; + +import arc.util.io.*; + +import java.io.*; + +/** + * Uses to write something to clear bytes + * */ +public class ByteWrites extends Writes{ + public final ReusableByteOutStream r = new ReusableByteOutStream(8192); + + public ByteWrites(){ + super(null); + output = new DataOutputStream(r); + } + public void reset(){ + r.reset(); + } + + public byte[] getBytes(){ + return r.toByteArray(); + } +}