본문 바로가기

카테고리 없음

로그 쌓기

반응형

private final String LOG_FILE_NAME = "download_file_log.txt"; 

 

/**
   * log 파일 쌓기
   */
  private void writeLog()
  {
   String log = "원하는 글을넣고"+ "\n";
   String filePath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/" + LOG_FILE_NAME;
   File file = new File(filePath);

   FileOutputStream fos = null;

   try
   {
    fos = new FileOutputStream(file, true);
    if (fos != null)
    {
     fos.write(log.getBytes());
    }
   }
   catch (FileNotFoundException e)
   {
    e.printStackTrace();
   }
   catch (IOException e)
   {
    e.printStackTrace();
   }
   finally
   {
    if (fos != null)
    {
     try
     {
      fos.close();
     }
     catch (IOException e)
     {
      e.printStackTrace();
     }
    }
   }

  } 

반응형