mirror of
https://github.com/Maschell/JNUSLib.git
synced 2024-11-22 07:59:19 +01:00
Add default implementiation for the readFile function of the FSTDataProvider interface
This commit is contained in:
parent
794d4b5146
commit
157957f3ee
@ -16,6 +16,7 @@
|
||||
****************************************************************************/
|
||||
package de.mas.wiiu.jnus.interfaces;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -30,11 +31,17 @@ public interface FSTDataProvider {
|
||||
|
||||
public FSTEntry getRoot();
|
||||
|
||||
public default byte[] readFile(FSTEntry entry) throws IOException {
|
||||
default public byte[] readFile(FSTEntry entry) throws IOException {
|
||||
return readFile(entry, 0, entry.getFileSize());
|
||||
}
|
||||
|
||||
public byte[] readFile(FSTEntry entry, long offset, long size) throws IOException;
|
||||
default public byte[] readFile(FSTEntry entry, long offset, long size) throws IOException {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
readFileToStream(out, entry, offset, Optional.of(size));
|
||||
|
||||
return out.toByteArray();
|
||||
}
|
||||
|
||||
default public InputStream readFileAsStream(FSTEntry entry) throws IOException {
|
||||
return readFileAsStream(entry, 0, Optional.empty());
|
||||
|
Loading…
Reference in New Issue
Block a user