设为首页 加入收藏

TOP

从相册获取图片及调用相机拍照获取图片,最后上传图片到服务器(三)
2017-10-13 10:47:30 】 浏览:8576
Tags:相册 获取 图片 调用 相机 拍照 最后 上传 服务器
er();
BufferedReader in = new BufferedReader(new InputStreamReader(conn
.getInputStream(), CHARSET));
String inputLine;
while ((inputLine = in.readLine()) != null) {
sb2.append(inputLine);
}
in.close();
tempStr = sb2.toString();
} catch (Exception e) {
} finally {
if (conn != null) {
conn.disconnect();
}
}
return tempStr;
}
 
/**
* Save Bitmap to a file. 保存图片到SD卡。
*
* @param bitmap
* @return error message if the saving is failed. null if the saving is
* successful.
* @throws IOException
*/
public static void saveBitmapToFile(Bitmap bitmap, String _file)
throws IOException {
BufferedOutputStream os = null;
try {
File file = new File(_file);
int end = _file.lastIndexOf(File.separator);
String _filePath = _file.substring(0, end);
File filePath = new File(_filePath);
if (!filePath.exists()) {
filePath.mkdirs();
}
file.createNewFile();
os = new BufferedOutputStream(new FileOutputStream(file));
bitmap.compress(Bitmap.CompressFormat.PNG, 100, os);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
}
}
}
}
}
首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Android高效计算——RenderScript.. 下一篇Android---闪频页和倒计时

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目