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 ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • 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("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: 4758
117
  • 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: 21462
96
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Related to https://coderanch.com/t/692675/recording-stream-mp.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!