您好,我在save = new FileOutputStream(path +filename)中得到一个错误;我不知道该怎么做,是媒体应用程序,此函数假定应用程序应将歌曲保存为铃声
public boolean saveas(int type, int position) {
Log.i("ramiro", "entro saveas");
byte[] buffer = null;
InputStream fIn = getBaseContext().getResources().openRawResource(
s1[position]);
int size = 0;
try {
size = fIn.available();
buffer = new byte[size];
fIn.read(buffer);
fIn.close();
} catch (IOException e) {
Log.i("ramiro", "error1 try");
return false;
}
String path = Environment.getExternalStorageDirectory().getPath()
+ "/media/audio/ringtones/";
String filename = title[position];
Log.i("ramiro", "filename: " + filename);
boolean exists = (new File(path)).exists();
if (!exists) {
new File(path).mkdirs();
}
FileOutputStream save;
try {
save = new FileOutputStream(path + filename); //error
save.write(buffer);
save.flush();
Log.i("ramiro", "paso flush");
save.close();
} catch (FileNotFoundException e) {
Log.i("ramiro", "try2 filenotfoundexception");
return false;
} catch (IOException e) {
Log.i("ramiro", "try2 ioexception");
return false;
}发布于 2014-02-16 20:41:10
替换这个
FileOutputStream save;使用
FileOutputStream save = null;发布于 2014-02-16 21:32:11
以下是您的问题:
此外,如果您的代码在添加了//错误注释的地方崩溃:
https://stackoverflow.com/questions/21811137
复制相似问题