public static void createFile(int id) {
try {
File dir = new File(Environment.getExternalStorageDirectory(), "1.wav");
InputStream ins = getResources().openRawResource(
id);// 通过raw得到数据资源
System.out.println("开始读入");
FileOutputStream fos = new FileOutputStream(dir);
System.out.println("开始写出");
byte[] buffer = new byte[8192];
int count = 0;// 循环写出
while ((count = ins.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
System.out.println("已经创建该文件");
fos.close();// 关闭流
ins.close();
} catch (Exception e) {
e.printStackTrace();
}
}