프로그래밍

안드로이드 파일 입출력

Bestend 2009. 12. 30. 13:51

[디렉토리 생성]
String appName = 이름을 가져온다
File dir = new File("/data/data/"+appName);
dir.mkdirs();    // 디렉토리 생성

[특정 데이터와 폴더 복사]
String [] Files;
FileList mFileList = new FileList();
Files =  mFileList.getList("/Orgsrc/data");

//파일입출력
public static void writeBitmap( Bitmap bitmap, String saveName, int page ) 

     File f = new File( "sdcard" + "/" + saveName + ".png");
  //File f = new File( DEFAULT_SAVE + "/" + saveName + ".png");
  
  FileOutputStream out = null;
  
  try
  {
   out = new FileOutputStream(f);
   bitmap.compress(CompressFormat.PNG, 100, out);
  }catch (FileNotFoundException e)
  {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }finally
  {
   try
   {
    out.close();
   }catch ( Exception e)
   {}
  }
 }