Currently, I have the following code that reads a file located on the Internet and writes it to a file on the phone:
InputStream inputStream = new URL(sourceFileWebAddress).openStream();
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
FileOutputStream fileOutputStream = new FileOutputStream(targetFile);
int count;
byte buffer[] = new byte[1024];
while ((count = bufferedInputStream.read(buffer, 0, buffer.length)) != -1)
fileOutputStream.write(buffer, 0, count);
Does anyone know if it is possible (using the setup above or otherwise) to determine the total number of bytes that should be read before starting with the download (to post the percentage progress for the user during the download process)
source
share