mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-14 14:02:49 +00:00
parent
7f09eb5535
commit
6770ccd3b1
5 changed files with 141 additions and 47 deletions
|
@ -1,12 +1,26 @@
|
|||
package me.impy.aegis.util;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ByteInputStream extends ByteArrayInputStream {
|
||||
public ByteInputStream(byte[] buf) {
|
||||
private ByteInputStream(byte[] buf) {
|
||||
super(buf);
|
||||
}
|
||||
|
||||
public static ByteInputStream create(InputStream fileStream) throws IOException {
|
||||
int read;
|
||||
byte[] buf = new byte[4096];
|
||||
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||
while ((read = fileStream.read(buf, 0, buf.length)) != -1) {
|
||||
outStream.write(buf, 0, read);
|
||||
}
|
||||
|
||||
return new ByteInputStream(outStream.toByteArray());
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return this.buf;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue