怎么把web服务器端获取的图片写入android客户端文件

移动开发 码拜 8年前 (2016-03-25) 1054次浏览
怎么把web服务器端数据库获取的图片写入android客户端文件
解决方案

10

获得图片,然后用FileoutputStream写入到文件……

10

先用htturlconnection(或其他方法也行)从服务器获得inputstream,然后再同过outputstream写入本地文件

10

你是想要直接要源码的吧,建议还是问google吧,就算给你了,你也需要修改的,这不就是更新下载么

50

web端从数据库获取图片,转换成字节流,
Android通过http获取到图片字节流,转成图片就可以了。

20

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();

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明怎么把web服务器端获取的图片写入android客户端文件
喜欢 (0)
[1034331897@qq.com]
分享 (0)