Saturday, March 8, 2014

How to get pictures web server write android client files


How to get the web server database writes pictures android client files<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Get the picture, and then written to the file ...... FileoutputStream
Reply:
First with htturlconnection (or other methods too) get inputstream from the server, and then write local files with over outputstream
Reply:
Are you want to direct to the source of it, it was suggested to ask google it, even to you, you also need to be modified, it is not that the update download
Reply:
web clients to obtain images from the database into a byte stream,
Android Gets a byte stream via http to the picture, turn into a picture on it.
Reply:
URL url = new URL (path);
URLConnection con = url.openConnection ();
InputStream input = con.getInputStream ();
int len;
byte [] buf = new byte [1024];
FileOutputStream output = new FileOutputStream (new File (phonePath));
while ((len = input.read (buf))! = -1)
{Output.write (buf, 0, len);}
output.close ();
input.close ();

No comments:

Post a Comment