try {
URL url=new URL("http://www.hogo.com.cn/zhongxue/amusement/music/lxgq/%b2%dc%b2%d9.mp3");
HttpURLConnection UrlCon=(HttpURLConnection) url.openConnection();
InputStream is=UrlCon.getInputStream();
File file = new File("/mnt/sdcard/cao.mp3");
OutputStream output = new FileOutputStream(file);
String str="",line;
//byte b=127;
byte[] buffer=new byte[4*1024];
while(is.read(buffer)!=-1){
output.write(buffer);
}
output.flush();
output.close();
Log.v("message", "ok");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
1.下载的cao.mp3不能播放?求解?
2.这个句有什么用:output.flush();如果把它删了,下载的歌曲还能正常播放么?
3.byte数组的大小与什么有关(有什么意思)
URL url=new URL("http://www.hogo.com.cn/zhongxue/amusement/music/lxgq/%b2%dc%b2%d9.mp3");
HttpURLConnection UrlCon=(HttpURLConnection) url.openConnection();
InputStream is=UrlCon.getInputStream();
File file = new File("/mnt/sdcard/cao.mp3");
OutputStream output = new FileOutputStream(file);
String str="",line;
//byte b=127;
byte[] buffer=new byte[4*1024];
while(is.read(buffer)!=-1){
output.write(buffer);
}
output.flush();
output.close();
Log.v("message", "ok");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
1.下载的cao.mp3不能播放?求解?
2.这个句有什么用:output.flush();如果把它删了,下载的歌曲还能正常播放么?
3.byte数组的大小与什么有关(有什么意思)
解决方案 »
- GestureDetector构造器弃用
- 求助android怎么创建一个图标
- 在Android应用程序中,了解XML文件操作的高手请进,能能解决的话分全给他
- android 创建控件create和findViewById的区别
- 和大家分享如何在模拟器上安装apk软件
- android liseView 点击事件中怎么传递adapter中的值
- 全局菜单的实现问题
- 我一调用sendTextMessage 程序就退出了 是怎么回事呢
- 经典的getLastKnownLocation返回null,试遍了已知方法,均无效~求助
- 怪异的问题,可以收到Android屏幕解锁广播,却无法收到黑屏及亮屏的广播
- ImageView中设置点击点, 点击后有不同TEXT出现
- 以下代码什么意思?
int len = 0;
//byte b=127;
byte[] buffer=new byte[1024];
while((len = is.read(buffer))!=-1){
output.write(buffer,0,len);
}试试吧