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) {
}
}
}
}
}