保存网络图片到手机上

// 保存图片到手机端
public static boolean saveNetImage(String url, String destPath)
{
	try
	{
		FileOutputStream fos = new FileOutputStream(destPath);
		InputStream is = new URL(url).openStream();

		int data = is.read();
		while (data != -1)
		{
			fos.write(data);
			data = is.read();
		}
		is.close();
		fos.close();
		
		return true;

	} catch (IOException e)
	{
		e.printStackTrace();
		return false;
	}
}

猜你喜欢

转载自liucanwen.iteye.com/blog/2047303