gpt4 book ai didi

android - 在android中写一个文件?

转载 作者:行者123 更新时间:2023-11-29 02:10:12 26 4
gpt4 key购买 nike

我得到了我的原始资源:

InputStream myRawResource = context.getActivity().getResources().openRawResource(myID);

如何将其写入文件?设备上的 MP3 文件。

最佳答案

try
{
File f=new File("myFile.mp3");
InputStream myRawResource = context.getActivity().getResources().openRawResource(myID);
OutputStream out=new FileOutputStream(f);
byte buf[]=new byte[1024];
int len;
while((len=myRawResource.read(buf))>0)
out.write(buf,0,len);
out.close();
myRawResource.close();
System.out.println("\nFile is created........
...........................");
}
catch (IOException e){}
}

关于android - 在android中写一个文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7932338/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com