Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7511423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:32:34+00:00 2026-05-29T23:32:34+00:00

I have an application playing remote MP3 files over HTTP using the JLayer/BasicPlayer libraries.

  • 0

I have an application playing remote MP3 files over HTTP using the JLayer/BasicPlayer libraries. I want to save the played mp3 files to disk without re-downloading them.

This is the code using the JLayer based BasicPlayer for Playing the MP3 file.

String mp3Url = "http://ia600402.us.archive.org/6/items/Stockfinster.-DeadLinesutemos025/01_Push_Push.mp3";
URL url = new URL(mp3Url);
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);

BasicPlayer player = new BasicPlayer();
player.open(bis);
player.play();

How would I save the mp3 file to disk?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T23:32:36+00:00Added an answer on May 29, 2026 at 11:32 pm

    To avoid having to go through the bytes twice, you need to wrap the input stream from the connection in a filter that writes any data that is read to an output stream, i.e. a kind of a “tee pipe input stream.” Such a class is not that difficult to write yourself, but you can save the work by using TeeInputStream from the Apache Commons IO library.

    Apache Commons IO: http://commons.apache.org/io/
    TeeInputStream javadoc: http://commons.apache.org/io/apidocs/org/apache/commons/io/input/TeeInputStream.html

    Edit: Proof-of-concept:

    import java.io.*;
    
    public class TeeInputStream extends InputStream {
        private InputStream in;
        private OutputStream out;
    
        public TeeInputStream(InputStream in, OutputStream branch) {
            this.in=in;
            this.out=branch;
        }
        public int read() throws IOException {
            int read = in.read();
            if (read != -1) out.write(read);
            return read;
        }
        public void close() throws IOException {
            in.close();
            out.close();
        }
    }
    

    How to use it:

    ...
    BufferedInputStream bis = new BufferedInputStream(is);
    TeeInputStream tis = new TeeInputStream(bis,new FileOutputStream("test.mp3"));
    
    BasicPlayer player = new BasicPlayer();
    player.open(tis);
    player.play();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using mpmovieplayer in my application.I have a button for playing movie witch
I have been playing around with a simple application for Windows Phone 7 using
I have an application that starts playing a sound when user touches the uiview
I have written some code for playing a .wav through my application. Now I
I have a simple ticket logging application build on LAMP. I am currently playing
In my application i have done to record the voice and playing in the
Greetings, I have an application that allows users to import libraries (.NET DLLs) they've
I have an application that loads external SWF files and plays them inside a
I´ve just started playing around with Java and Hibernate and have gotten an application
I have a WinForms application (I'm using VB) that can be minimized to the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.