I am having a problem, been trying to couple the knowledge from this post and this.
My simple first approach was to try and download that sunny.gif as well as you did, what I want to do then is to save to the drive.
The code I have been jumbling with is this:
- Code: Select all
try
{
URL myURL = new URL("http://www.google.com/images/weather/sunny.gif");
URLConnection conn = myURL.openConnection();
conn.connect();
InputStream is = conn.getInputStream();
FileOutputStream fOut = openFileOutput("sunny.gif", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(is);
osw.flush();
osw.close();
}
catch(Exception e)
{
}
I don't really understand all the concepts to the bottom, but I get an error with the osw.write, the error in the tooltip is:
"The method write(int) in the type OutputStreamWriter is not applicable for the arguments (InputStream)"
Hope you can help me out, since my ultimate goal is to have my app download a file from a server and then do stopwatch timer on the time it takes to get the file, since I need this time to calculate on connectivity and such.


