Hi.,
I have a file in my server which is of huge size. Need to download that from my client.
Below is the method i use to read to do the same.
byte[] bytes = null;
File report = new File(absolutePath);
StringBuffer os = new StringBuffer();
if (report != null && report.exists() && report.isFile()) {
BufferedInputStream input = null;
try {
input = new BufferedInputStream(new FileInputStream(report));
bytes = new byte[(int) report.length()];
int buf = 1024;
int i=0;
while(true){
if(input.available() <= 1024){
input.read(bytes , buf*i, input.available());
break;
}
else
{
input.read(bytes , buf*i, buf);
}
i++;
}
....
.....
but it fails here bytes = new byte[(int) report.length()];
because the length of the file is too big.
Can you please suggest some other way to read large files in
java.