안드로이드 개발 질문/답변
(글 수 45,052)
비트맵 이미지를 sdcard에 파일로 저장하려고 하는데 output stream 을 만들면 익셉션 처리가 됩니다.
로그를 살펴보면 이런 로그가 발생하면서 익셉션처리됩니다.
java.io.FileNotFoundException: /mnt/sdcard/EmotionCamera/EmotionCamera1353987050407.jpg: open failed : ENOENT(No such file or directory)
private void saveBitmapToFile( Bitmap bitmap, String fileName ){
try {
String imageName = "/EmotionCamera/" + fileName + ".jpg";
File newFile = new File(Environment.getExternalStorageDirectory(), imageName );
//newFile.createNewFile();
FileOutputStream fileOutputStream = new FileOutputStream( newFile );
BufferedOutputStream bos = new BufferedOutputStream(fileOutputStream);
bitmap.compress(CompressFormat.JPEG, 100, bos);
bos.flush();
bos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.emotioncamera"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
인터넷을 찾아보니 퍼미션 안해줄때 발생한다던데
이렇게 퍼미션 넣어 주었는데도 오류가 발생합니다.
도와주십시요 ㅠㅠ
공지사항을 다 읽었음




EmotionCamera 라는 디렉터리가 없어서 그런 것 같은데요.
스트림을 생성하기 전에 디렉터리가 있는지 먼저 확인하셔야 할 듯 해요.