title: Fetching MP3-Tags while recording a stream using java
body: <p>I currently have this code, which successfully records an (mp3-)stream:</p>
  
  <pre><code>public class Recorder {
      private static final int BUFFER_SIZE = 2048;
  
      private Thread thread;
      private boolean running = false;
  
      public Recorder(URL stream, File dest) {
          thread = new Thread(() -&gt; {
              try {
                  URLConnection connection = stream.openConnection();
                  InputStream inStream = connection.getInputStream();
  
                  OutputStream outStream = new FileOutputStream(dest);
                  byte[] buffer = new byte[BUFFER_SIZE];
                  int length;
  
                  System.out.println("Now recording " + stream.toString());
  
                  while ((length = inStream.read(buffer)) &gt; 0 &amp;&amp; running) {
                      outStream.write(buffer, 0, length);
                  }
  
                  outStream.close();
              } catch (IOException e) {
                  e.printStackTrace();
              }
          });
      }
  
      public void start() {
          running = true;
          thread.start();
      }
  
      public void stop() {
          running = false;
          try {
              thread.join();
          } catch (InterruptedException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>How do I read the MP3-tags (song title and artist name) from the stream properly? I've found a few answers on how to fetch the MP3-tags from files, but not from streaming audio.</p>
  
  <p>Thanks.</p>