title: How to save simpleCaptcha wav file in java
body: <p>I need to save the file to play <code>Simplecaptcha</code> voice file on IOS and succeeded in saving the file in a folder I want.</p>
  
  <p>But I tried to play the wav file in the folder(double click), It wasn't replayed.</p>
  
  <p>Please help me</p>
  
  <pre><code>public static void saveAudio(final HttpServletRequest request, final HttpServletResponse response, final Sample sample) {
  
          String fileName = request.getParameter("fileName");
          try {
  
              final ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
              AudioSystem.write(sample.getAudioInputStream(), AudioFileFormat.Type.WAVE, baos);
  
              byte audioData[] = baos.toByteArray();
  
              AudioFormat af = new AudioFormat(16000.0F, 16, 1,true, false); // simplecaptcha default setting 
              ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
              AudioInputStream ais = new AudioInputStream(bais, af , audioData.length);   
              AudioSystem.write(ais, AudioFileFormat.Type.WAVE, new File("/audio/"+fileName+".wav")); 
  
          } catch (IOException e) {
              System.out.println(e);
  
          }      
      }
  </code></pre>