View Javadoc

1   /*
2    * JCaptcha, the open source java framework for captcha definition and integration
3    * Copyright (c)  2007 jcaptcha.net. All Rights Reserved.
4    * See the LICENSE.txt file distributed with this package.
5    */
6   
7   /*
8    * jcaptcha, the open source java framework for captcha definition and integration
9    * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
10   * See the LICENSE.txt file distributed with this package.
11   */
12  
13  /*
14   * jcaptcha, the open source java framework for captcha definition and integration
15   * copyright (c)  2007 jcaptcha.net. All Rights Reserved.
16   * See the LICENSE.txt file distributed with this package.
17   */
18  package com.octo.captcha.engine.sound.utils;
19  
20  import javax.sound.sampled.AudioFileFormat;
21  import javax.sound.sampled.AudioInputStream;
22  import javax.sound.sampled.AudioSystem;
23  import java.io.File;
24  import java.io.IOException;
25  
26  /***
27   * <p/>
28   * Create a wave file from an AudioInputStream </p>
29   *
30   * @author Benoit
31   * @version 1.0
32   */
33  public class SoundToFile {
34      /***
35       * Create a wave file from an AudioInputStream
36       *
37       * @param pAudioInputStream Audio Steam to serialize
38       * @param pFile             File to write to audio stream
39       */
40      public static void serialize(AudioInputStream pAudioInputStream, File pFile) throws IOException {
41          pFile.createNewFile();
42          AudioSystem.write(pAudioInputStream, AudioFileFormat.Type.WAVE, pFile);
43      }
44  }