Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java forum!
    Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

downloading mp3 from stream  RSS feed

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Report post to moderator
can some tell me what im doing wrong here im trying to execute this code using AsyncTask but i can't seem to getting to work. here is the code

class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
           protected Long doInBackground(URL... urls) {
               try {

                   URLConnection conn = new URL("http://50.7.70.58:8838/live").openConnection();
                   InputStream is = conn.getInputStream();

                   OutputStream outstream = new FileOutputStream(new File("/mnt/sdcard/Download/file.mp3"));
                   byte[] buffer = new byte[4096];
                   int len;
                   while ((len = is.read(buffer)) > 0) {
                       outstream.write(buffer, 0, len);
                   }
                   outstream.close();
               } catch (IOException e) {
                   e.printStackTrace();
               }

           }
       }


       new DownloadFilesTask().execute();
 
Saloon Keeper
Posts: 5133
135
  • Mark post as helpful
  • send pies
  • Report post to moderator
What does the code do, and what should it be doing instead? Where does the observed behavior start to deviate from the expected behavior?
 
Sheriff
Posts: 21558
100
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Related to https://coderanch.com/t/692675/recording-stream-mp.
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!