기술/beginning games2011. 5. 31. 20:07
download download
public interface FileIO {         // 인터페이스 생성
public InputStream readAsset(String fileName) throws IOException;    //Asset Input
public InputStream readFile(String fileName) throws IOException;      //File Input
public OutputStream writeFile(String fileName) throws IOException;   //File Output
}


import com.badlogic.androidgames.framework.FileIO;

public class AndroidFileIO implements FileIO{
AssetManager assets;
String externalStoragePath;

public AndroidFileIO(AssetManager assets){
this.assets = assets;
this.externalStoragePath = Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator;  //외부 저장장치 경로 설정
}
@Override
public InputStream readAsset(String fileName) throws IOException {
return assets.open(fileName);
}

@Override
public InputStream readFile(String fileName) throws IOException {
return new FileInputStream(externalStoragePath + fileName);
}

@Override
public OutputStream writeFile(String fileName) throws IOException {
return new FileOutputStream(externalStoragePath + fileName);
}
}
download download download
Posted by yachtie_leo