java播放wav的基础代码
import java.io.*;
public class TestMusic{
private AudioFormat format;
private byte[] samples;
public static void main(String args[])throws Exception{
TestMusic sound =new TestMusic("1.wav");
InputStream stream =new ByteArrayInputStream(sound.getSamples());
// play the sound
sound.play(stream);
// exit
System.exit(0);
}
public TestMusic(String filename) {
try {
// open the audio input stream
AudioInputStream stream =AudioSystem.getAudioInputStream(new File(filename));
format = stream.getFormat();
// get the audio samples
samples = getSamples(stream);
}
catch (UnsupportedAudioFileException ex) {
ex.printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
public byte[] getSamples() {
return samples;
}
private byte[] getSamples(AudioInputStream audioStream) {
// get th
相关文档:
先来了解一下链表模式的原理:
首先写一个JavaBean,内容是要添加的元素和该元素的节点。
public class NodeBean implements Serializable
{
private Object data; //元素本身
private NodeBean next; //下一个节点
&n ......
////////////////////////////////////////////////节点类 TreeNode.java //////////////////////////
package com.tree;
class TreeNode {//包访问权限
long data ;
long x,y;
String adrr;
Tre ......
学习了几周,玩得很开心。
学习java的第一件事就是做一个程序生成Huffman编码。
在这里我学会了LinkedList的使用,它可以保存任何类型的对象。
如下是我的编码结构体
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package HuffmanTree;
......