I was able to read files less than 2GB from http location. However if I try to read files greater then 2 GB I get exception. I am not reading fully instead reading in chunks. Below is my code snippet and exception message. Help me incase if you have a clue to proceed further
BufferedOutputStream bos = new BufferedOutputStream(os);
URL url = new URL(fileName);
LOGGER.debug(url.toString());
URLConnection connection = url.openConnection();
LOGGER.debug("Before getting input stream 100 MB, open input stream::" + downloadFileName);
// BufferedInputStream in = new BufferedInputStream(url.openStream());
InputStream in = url.openStream();
// InputStreamReader inReader = new InputStreamReader(in);
// InputStream in = connection.getInputStream();
LOGGER.debug("Afters getting input stream, open inputstream::" + downloadFileName);
// in.
// LOGGER.debug("in1::" + in1);
final byte[] buffer = new byte[100 * 1024 * 1024]; // 100Mb
while (true)
{
LOGGER.debug("Reading..");
final int read = in.read(buffer);
LOGGER.debug("Read..");
if (read < 0)
{
break;
}
LOGGER.debug("Writing..");
bos.write(buffer, 0, read);
LOGGER.debug("Wrote..");
// bos.
}