Possible Duplicate:
Resize an image in Java - Any Open Source Library ?
InputStream is = new FileInputStream(file)开发者_开发百科;
long length = file.length();
// if (length > Integer.MAX_VALUE) {
// File is too large
// }
byte[] bytes = new byte[(int) length];
if i enter large image....it should accept but size should be reduced
- Image resize in Java
- Java Image Manupulation
First, you should use a buffer and read the data in buffer-size increments, otherwise you will probably have problems when the data is big.
Second, as suggested by other users, you should use compression, or, since we are talking about images, you can always downsample it as a last resource, if you are in a very memory constrained environment.
精彩评论