android模拟器下如何实现下载文件的功能 课程设计要求在android1.5模拟器下实现播放器,并且要求有音乐下载功能,希望哪位可以给个可以用来下载的代码,最好是源文件包,在此谢过~~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 下载MP3文件代码:try { //读取链接地址歌曲文件流 URL url = new URL(musicURL); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoInput(true); conn.connect(); InputStream is = conn.getInputStream(); //创建本地保存流的文件 File musicFile = new File("/sdcard/", xxx.mp3); FileOutputStream fos = new FileOutputStream(musicFile); byte[] bt = new byte[1024]; int i = 0; while ( (i = is.read(bt)) > 0 ) { fos.write(bt, 0, i); } fos.close(); is.close(); 怎样将一个wav文件 打包进 dpk 文件里? 还有要程序怎样访问这个打包的wav文件? android开机震动代码 新手,opengl入门问题,跪求大神指导!! 请教“服务器端软件开发 ”/“系统研究开发”如何翻译 求比较好的TAB框架 [Android]怎样得到Google AdSense account? 请教一个关于ListView实现类似EXCEL中冻结窗口的问题 安卓手机搭建php环境 Android删除最近使用过的程序? H5唤醒微信跳转微信里的指定界面,请教各位大神,万分感谢! handler如何控制更新某个控制 android中context怎么注入到Activity中的
try {
//读取链接地址歌曲文件流
URL url = new URL(musicURL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
//创建本地保存流的文件
File musicFile = new File("/sdcard/", xxx.mp3);
FileOutputStream fos = new FileOutputStream(musicFile);
byte[] bt = new byte[1024];
int i = 0;
while ( (i = is.read(bt)) > 0 )
{
fos.write(bt, 0, i);
}
fos.close();
is.close();