Catch OutOfMemoryError when writing

This commit is contained in:
J-Jamet
2018-04-03 13:07:05 +02:00
parent 8105f89088
commit d8e3d52f21

View File

@@ -52,9 +52,13 @@ public class Util {
public static void copyStream(InputStream in, OutputStream out) throws IOException {
byte[] buf = new byte[1024];
int read;
while ((read = in.read(buf)) != -1) {
out.write(buf, 0, read);
}
try {
while ((read = in.read(buf)) != -1) {
out.write(buf, 0, read);
}
} catch (OutOfMemoryError error) {
throw new IOException(error);
}
}
private final static String stringToStrikeThrough = "0";