获取各种路径:
http://blog.csdn.net/qq_26296197/article/details/51909423
内部保存:
http://blog.csdn.net/csdnzouqi/article/details/51938883
http://www.cnblogs.com/LiHuiGe8/p/5604725.html
http://www.cnblogs.com/bastard/archive/2013/03/04/2943302.html
外部保存:
例子:
内部保存:
1. 获取缓存路径 主要时context对象。handler是做其他留下来的很本例程无关
public TCPView(Handler handler, Context context){2. 保存
this.mHandler = handler;
this.jpeg = new JpegStream();
// LocalPhoto = Environment.getDownloadCacheDirectory().getPath();
LocalPhoto = context.getCacheDir().getPath();
}
private File getFileFromBytes(byte[] b, String outputFile) {3. 使用即可
BufferedOutputStream stream = null;
FileOutputStream fstream = null;
File file = null;
try {
file = new File(outputFile,"1.jpg");
if(file.exists()) {
file.delete();
}
file.createNewFile();
fstream = new FileOutputStream(file);
stream = new BufferedOutputStream(fstream);
stream.write(b);
stream.flush();
fstream.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
if (fstream != null) {
try {
fstream.close();
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
return file;
}