public class BufferedWriterFactory {
    public static 
BufferedWriter create(String path, String TextFileName) throws IOException 
{

     File filePath = new 
File(path);
        if 
(!filePath.exists())
            
filePath.mkdirs();
        BufferedWriter bw = new 
BufferedWriter(new FileWriter(path + File.separator + 
TextFileName));
        return 
bw;
    }
}

class ButtonSaveClickListener implements OnClickListener {
        Context 
 context;
        

        public 
 ButtonSaveClickListener(Context context) 
 {
            
 this.context = context;
        }
 public void onClick(View 
 v){
  mChrono.stop();
  String TextFileName = 
 ""+mYear+""+mMonth+""+mDay+".txt" ;
  String TextContent =  
 mChrono.getText().toString();
  BufferedWriter bw = null;
  try{
   bw = 
 BufferedWriterFactory.create("/sdcard/RespirationCheck",TextFileName);
   bw.write(TextContent); 

   Toast.makeText(this.context, "성공적으로 기록하였습니다.", 
Toast.LENGTH_SHORT).show();
  }
  catch(IOException 
 e){
   String exceptionMessage = TextFileName + " 파일에 기록할 수 
 없습니다.";
            
Toast.makeText(this.context, exceptionMessage, 
 Toast.LENGTH_SHORT).show();
            
 e.printStackTrace();
  }  
    catch 
 (Exception e) 
 {
              
 Toast.makeText(this.context, "알 수 없는 오류입니다.", 
Toast.LENGTH_SHORT).show();
              
 e.printStackTrace();
          
 }         

          try 
 {
              
 if (null != 
 bw)
                  
 bw.close();
          
 }
          catch (IOException 
 e) 
 {
              
 Toast.makeText(this.context, TextFileName + "파일을 닫을 수 없습니다.", 
Toast.LENGTH_SHORT).show();
              
 e.printStackTrace();
          
 }
      }
 }

 

 


 

 

메니페스트에 퍼미션도 주고 다음과 같이 코드도 작성하였는데 계속 파일에 기록할수 없습니다만 뜨네요 ㅜㅠ 왜이럴까요

12-19 15:58:19.152: E/Trace(964): error opening trace file: No such file or directory (2)
이건 로그캣 빨간 부분입니다.

 

처음올리는 질문입니다. 공지사항읽었습니다.