Ich schreibe eine Funktion Datei herunterzuladen:android Download Fortschritt
URL _url = new URL("http://kevin95800.free.fr/Music/Jay%20Sean%20-%20Down%20(ft.%20Lil%20Wayne).mp3");
URLConnection conn = _url.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
if(is == null)
{
throw new RuntimeException("stream is null");
}
File musicFile = new File("/sdcard/music/" , "mitpig.mp3");
FileOutputStream fos = new FileOutputStream(musicFile);
byte buf[] = new byte[128];
do
{
int numread = is.read(buf);
Log.i("html2" , numread+" ");
if(numread <=0)
break;
fos.write(buf , 0 , numread);
}while(true);
is.close();
meine Frage ist, wie kann ich wissen, das gesamte Byte der Datei bin Download i ??
weil ich den Download-Fortschritt anzeigen möchte. könnte mir jemand beibringen