download
download
import com.badlogic.androidgames.framework.FileIO;
download
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);
}
}