Read buffer helper

This commit is contained in:
M66B
2020-09-16 20:30:40 +02:00
parent 1c0101b43e
commit 571ed13f0b
2 changed files with 12 additions and 4 deletions

View File

@@ -1124,6 +1124,16 @@ public class Helper {
}
}
public static void readBuffer(InputStream is, byte[] buffer) throws IOException {
int left = buffer.length;
while (left > 0) {
int count = is.read(buffer, buffer.length - left, left);
if (count < 0)
throw new IOException("EOF");
left -= count;
}
}
static void copy(File src, File dst) throws IOException {
try (InputStream in = new FileInputStream(src)) {
try (FileOutputStream out = new FileOutputStream(dst)) {