title: Java - save Internet Radio stream
body: <p>i want to record a internet radio show that is running during midday, where i cann´t listen to it.</p>
  
  <p>The URL of the radio is:
  <a href="http://radio.orf.at/player/radioplayer.html?station=ooe" rel="nofollow">http://radio.orf.at/player/radioplayer.html?station=ooe</a></p>
  
  <p>I looked at the DOM to find out where the player gets its data from.
  I believe that it is this server:
  "http://194.232.200.148:8000"</p>
  
  <p>When i type this in my browser a documents appears which grows over the time, so i assume its the data of the stream.</p>
  
  <p>As I read in the DOM the data is in the audio/mpeg format, so i thought i could write a little program that grabs the data and just saves it as a *.mpeg file.</p>
  
  <p>My test program looks like:</p>
  
  <pre><code>URL u = new URL("http://194.232.200.148:8000");
              InputStream openStream = u.openStream();
              long curTime = System.currentTimeMillis();
              BufferedWriter bw = null;
  
              FileWriter fw = new FileWriter(new File("C:\\Users\\Lukas\\Desktop\\test.mpeg"));
              bw = new BufferedWriter(fw);
              while (true) {
                  int read = openStream.read();
  
                  System.out.println(read);
                  if (read == -1 || curTime + 60000 &lt; System.currentTimeMillis()) {
                      break;
                  }
                  bw.write(read);
                  bw.flush();
  
              }
              bw.close();
          } catch (Exception ex) {
              Logger.getLogger(Test.class.getName()).log(Level.SEVERE, null, ex);
          }
  </code></pre>
  
  <p>But as i already feared, it seems that it´s is not that easy.</p>
  
  <p>I get the data to the file, but it´s not an valid .mpeg file.</p>
  
  <p>So i wanted to ask if anyone has experience with this kind of issues and can help me solve the problem or atleast give me a hint what to do.</p>
  
  <p>yours, Lukas</p>