-
FEATURED COMPONENTS
First time here? Check out the FAQ!
1 | initial version | |
otherwise you can count the written bytes and stop it after 2gb
final long MAX_SIZE = 2147483648L;
long currentSize = 0;
byte[] buffer = new byte[1024 * 8];
for (int count; (count = inputStream.read(buffer)) != -1;) {
outputStream.write(buffer, 0, count);
currentSize += count;
if (currentSize >= MAX_SIZE) {
System.out.println("too big!");
break;
}
}
2 | No.2 Revision |
otherwise you can count the written bytes and stop it after 2gb
final long MAX_SIZE = 2147483648L;
long currentSize = 0;
byte[] buffer = new byte[1024 * 8];
for (int count; (count = inputStream.read(buffer)) != -1;) {
{ outputStream.write(buffer, 0, count);
currentSize += count;
if (currentSize >= MAX_SIZE) {
System.out.println("too big!");
break;
}
outputStream.write(buffer, 0, count);
}