class DownloadTxtListener implements OnClickListener{ @Override
public void onClick(View v) {
// TODO Auto-generated method stub
String StringUrl="http://lrc.bzmtv.com/lrc_db/2011-6-1-JNDRIMFOJNGJNQQLRFNPNF0-173757.lrc";
try {
System.out.print("1");
StringBuffer sb=null;
String line=null;
URL txtUrl=new URL(StringUrl);
BufferedReader buffer=null;
System.out.print("2");
HttpURLConnection urlConn=(HttpURLConnection) txtUrl.openConnection();
buffer=new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
System.out.print("3");
while((line = buffer.readLine())!= null){
sb.append(line);
}
System.out.print(sb.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}貌似是这个链接不对 ,我跟着教程里面的方法写的 ,该贴入什么样的链接呢
public void onClick(View v) {
// TODO Auto-generated method stub
String StringUrl="http://lrc.bzmtv.com/lrc_db/2011-6-1-JNDRIMFOJNGJNQQLRFNPNF0-173757.lrc";
try {
System.out.print("1");
StringBuffer sb=null;
String line=null;
URL txtUrl=new URL(StringUrl);
BufferedReader buffer=null;
System.out.print("2");
HttpURLConnection urlConn=(HttpURLConnection) txtUrl.openConnection();
buffer=new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
System.out.print("3");
while((line = buffer.readLine())!= null){
sb.append(line);
}
System.out.print(sb.toString());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}貌似是这个链接不对 ,我跟着教程里面的方法写的 ,该贴入什么样的链接呢
<uses-permission android:name="android.permission.INTERNET"></uses-permission>给个邮箱,可以发给你具体的代码。
没有初始化就append,所以空了