Java 怎么确定采样音频文件的编码

2019年7月29日20:07:25Java 怎么确定采样音频文件的编码已关闭评论 481 786字阅读2分37秒

1.简介

Java 怎么确定采样音频文件的编码?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;

import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.UnsupportedAudioFileException;

public class Main {
  public static void main(String[] args) throws Exception {
    try {
      
      AudioInputStream stream = AudioSystem.getAudioInputStream(new File(
          "audiofile"));

      
      stream = AudioSystem.getAudioInputStream(new URL(
          "http:

      AudioFormat format = stream.getFormat();
      if (format.getEncoding() == AudioFormat.Encoding.ULAW) {
      } else if (format.getEncoding() == AudioFormat.Encoding.ULAW) {
      }
    } catch (MalformedURLException e) {
    } catch (IOException e) {
    } catch (UnsupportedAudioFileException e) {
      
    }
  }
}

 
编程十万个怎么办