package SST.com.tw;

import java.io.*;
import javax.sound.sampled.*;

public class AP_Main {
    static ByteArrayOutputStream bos = new ByteArrayOutputStream();
    public static void main(String args[]) {
        try {
            File file = new File ("D:\\aa.au");
            InputStream in = new FileInputStream(file);
            AudioInputStream AIS = AudioSystem.getAudioInputStream(file);
            AudioFormat format = AIS.getFormat();
            DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
            SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);
            line.open(format);
            line.start();
            int bufferSize = (int) format.getSampleRate() * format.getFrameSize();
            byte[] buffer = new byte[bufferSize];
            try {
                int bytesRead = 0;
                while (bytesRead >= 0) {
                    bytesRead = AIS.read(buffer, 0, buffer.length);
                    if (bytesRead >= 0) {
                        line.write(buffer, 0, bytesRead);
                    }
                }
            } catch (IOException e) {
                System.out.println("" + e.toString());
            }
            line.close();
            System.out.println("program over");
       } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ffyy99 的頭像
    ffyy99

    喜歡亂搞的世界

    ffyy99 發表在 痞客邦 留言(0) 人氣()