Back to project page camera.
The source code is released under:
Apache License
If you think the Android project camera listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.yanzi.util; /* w ww . j av a 2s . co m*/ import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import android.graphics.Bitmap; import android.os.Environment; import android.util.Log; public class FileUtil { private static final String TAG = "FileUtil"; private static final File parentPath = Environment.getExternalStorageDirectory(); private static String storagePath = ""; private static final String DST_FOLDER_NAME = "PlayCamera"; /**??????????? * @return */ private static String initPath(){ if(storagePath.equals("")){ storagePath = parentPath.getAbsolutePath()+"/" + DST_FOLDER_NAME; File f = new File(storagePath); if(!f.exists()){ f.mkdir(); } } return storagePath; } /**????Bitmap??sdcard * @param b */ public static void saveBitmap(Bitmap b){ String path = initPath(); long dataTake = System.currentTimeMillis(); String jpegName = path + "/" + dataTake +".jpg"; Log.i(TAG, "saveBitmap:jpegName = " + jpegName); try { FileOutputStream fout = new FileOutputStream(jpegName); BufferedOutputStream bos = new BufferedOutputStream(fout); b.compress(Bitmap.CompressFormat.JPEG, 100, bos); bos.flush(); bos.close(); Log.i(TAG, "saveBitmap???"); } catch (IOException e) { // TODO Auto-generated catch block Log.i(TAG, "saveBitmap:???"); e.printStackTrace(); } } }