Saving part of an audio file (Java)
<p>While playing an audio file (.wav) I want, if I resort to <kbd>Ctrl</kbd>+<kbd>C</kbd>, to stop the playback and save part of the audio file in a file called "file2.wav".</p>

<p>Here's the thread I'd like to add to my code.
Unfortunately it doesn't work at all.</p>

<hr>

<pre><code>class myThread extends Thread{

    public void run(){
        try {
            PipedOutputStream poStream = new PipedOutputStream();
            PipedInputStream piStream = new PipedInputStream();
            poStream.connect(piStream);
            File cutaudioFile = new File ("file2.wav");

            AudioInputStream ais =
              new AudioInputStream(piStream,
                                   AudioFileFormat.Type.WAVE,
                                   cutaudioFile);
            poStream.write(ais,AudioFileFormat.Type.WAVE,cutaudioFile);
        }catch (Exception e){
            e.printStackTrace();
        }
    } // end run
} // end myThread
</code></pre>

<hr>
