• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

link to connection keeps crashing

I'm trying to recored url music stream but for some reason it keeps crashing when i run it with this line InputStream is = conn.getInputStream(); here is the code im using.


URLConnection conn = null;


conn = new URL("http://50.7.70.58:8708").openConnection();

InputStream is = conn.getInputStream();


OutputStream outstream = new FileOutputStream(new File("/mnt/sdcard/Music/output.mp3"));

byte[] buffer = new byte[4096];
int len;


while ((len = is.read(buffer)) > 0) {

outstream.write(buffer, 0, len);

}
outstream.close();
 
Back
Top Bottom