public void writePhoto(String picName){
Bitmap bmp = BitmapFactory.decodeFile("/sdcard/FaceDetect/facedone.jpg");
String filefolder =Environment.getExternalStorageDirectory()+"/FaDa/";
File parent = new File(filefolder);
if (!parent.exists()) {
//若不存在,创建目录,可以在应用启动的时候创建
parent.mkdirs();
Log.i("llll","parent = " + parent.exists());
}
String path = filefolder + picName + ".jpg";
File file = new File(path);
String paht1=file.getAbsolutePath();
Log.i("llll","path1 = " + path);
if(file.exists()){
file.delete();
}
try {
file.createNewFile();
Log.i("llll","createNewFile");
} catch (IOException e) {
e.printStackTrace();
}
FileOutputStream fOut = null;
try {
Log.i("llll","createNewFile");
fOut = new FileOutputStream(file);
}catch (FileNotFoundException e){
e.printStackTrace();
}
Log.i("llll","fOut = " +(fOut != null));
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
try {
fOut.flush();
fOut.close();
}catch (IOException e){
e.printStackTrace();
}
}
Bitmap bmp = BitmapFactory.decodeFile("/sdcard/FaceDetect/facedone.jpg");
String filefolder =Environment.getExternalStorageDirectory()+"/FaDa/";
File parent = new File(filefolder);
if (!parent.exists()) {
//若不存在,创建目录,可以在应用启动的时候创建
parent.mkdirs();
Log.i("llll","parent = " + parent.exists());
}
String path = filefolder + picName + ".jpg";
File file = new File(path);
String paht1=file.getAbsolutePath();
Log.i("llll","path1 = " + path);
if(file.exists()){
file.delete();
}
try {
file.createNewFile();
Log.i("llll","createNewFile");
} catch (IOException e) {
e.printStackTrace();
}
FileOutputStream fOut = null;
try {
Log.i("llll","createNewFile");
fOut = new FileOutputStream(file);
}catch (FileNotFoundException e){
e.printStackTrace();
}
Log.i("llll","fOut = " +(fOut != null));
bmp.compress(Bitmap.CompressFormat.JPEG, 100, fOut);
try {
fOut.flush();
fOut.close();
}catch (IOException e){
e.printStackTrace();
}
}