Hello,
I really dont know why file.lengt returns 0 all the time, can u help
me ?
public void getFileFromInternet(String tempUrl) {
HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(tempUrl);
try {
HttpResponse response = httpClient.execute(httpGet);
response = httpClient.execute(httpGet);
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();
File myNewFile = new File("test.tmp");
FileOutputStream out =
context.openFileOutput(myNewFile.getName(),
Context.MODE_WORLD_WRITEABLE);
byte buf[] = new byte[1024];
int len;
while ((len = inputStream.read(buf)) > 0)
out.write(buf, 0, len);
out.close();
inputStream.close();
Log.d("TEST", Long.toString(myNewFile.length()));
// myNewFile.length() is always 0 although the file is stored in the
DDMS and is bigger than 0
} catch (Exception e) {
e.printStackTrace();
}
httpClient.getConnectionManager().shutdown();
}
Can anyone tell me what I did wrong ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---