Download Large Files using java
Posted
by angelina
on Stack Overflow
See other posts from Stack Overflow
or by angelina
Published on 2010-05-13T09:00:49Z
Indexed on
2010/05/13
9:04 UTC
Read the original article
Hit count: 190
java
Dear All, I M building a application in which i want to download large files on handset (mobile),but if size of file is large i m getting exception socket exception-broken pipe .
inputStream = new FileInputStream(path);
byte[] buffer = new byte[1024];
int bytesRead = 0;
do
{
bytesRead = inputStream.read(buffer, offset, buffer.length);
resp.getOutputStream().write(buffer, 0, bytesRead);
}
while (bytesRead == buffer.length);
resp.getOutputStream().flush();
}
© Stack Overflow or respective owner