This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing 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 ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

downloading mp3 from stream  RSS feed

Ranch Hand
Posts: 62
  • 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("").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 = > 0) {
                        outstream.write(buffer, 0, len);
                } catch (IOException e) {


        new DownloadFilesTask().execute();
Saloon Keeper
Posts: 4758
  • 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?
Posts: 21462
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Related to
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!