public class AudioInputStream extends InputStream
的AudioSystem
类包括许多方法AudioInputStream
对象操作。例如,方法让你:
AudioSystem
,
Clip.open(AudioInputStream)
Modifier and Type | Field and Description |
---|---|
protected AudioFormat |
format
流中包含的音频数据的格式。
|
protected long |
frameLength
此流的长度,在样本帧中。
|
protected long |
framePos
在这个流中的当前位置,在样本帧(基于零)。
|
protected int |
frameSize
每个帧的大小,以字节为单位。
|
Constructor and Description |
---|
AudioInputStream(InputStream stream, AudioFormat format, long length)
构造一个有请求的格式和长度的音频输入流,使用从指定的输入流的音频数据。
|
AudioInputStream(TargetDataLine line)
构建一个从目标数据线读取数据的音频输入流。
|
Modifier and Type | Method and Description |
---|---|
int |
available()
返回从没有阻塞的音频输入流中读取的最大字节数(或跳过)。
|
void |
close()
关闭此音频输入流并释放与流关联的任何系统资源。
|
AudioFormat |
getFormat()
获取此音频输入流中的声音数据的音频格式。
|
long |
getFrameLength()
获取流的长度,用示例帧表示,而不是字节表示的长度。
|
void |
mark(int readlimit)
标记此音频输入流中的当前位置。
|
boolean |
markSupported()
测试是否这个音频输入流的支持
mark 和
reset 方法。
|
int |
read()
从音频输入流中读取下一个字节的数据。
|
int |
read(byte[] b)
读取一定数量的字节从音频输入流并存入缓冲区阵列
b 。
|
int |
read(byte[] b, int off, int len)
读取到指定的从音频流中的数据的最大字节数,将它们放入给定的字节数组中。
|
void |
reset()
重新定位该音频输入流的位置,它在时间上的
mark 方法调用。
|
long |
skip(long n)
跳过并丢弃指定的字节数从这个音频输入流。
|
protected AudioFormat format
protected long frameLength
protected int frameSize
protected long framePos
public AudioInputStream(InputStream stream, AudioFormat format, long length)
stream
流-这
AudioInputStream
对象的基础
format
-这流的音频数据格式
length
在这流样本数据帧长度
public AudioInputStream(TargetDataLine line)
line
-目标数据线从该流获得数据。
AudioSystem.NOT_SPECIFIED
public AudioFormat getFormat()
public long getFrameLength()
public int read() throws IOException
IOException
将抛出。
read
方法重写,继承类
InputStream
IOException
如果输入或输出错误发生
read(byte[], int, int)
,
read(byte[])
,
public int read(byte[] b) throws IOException
b
。实际读取的字节数作为一个整数返回。此方法块,直到输入数据可用,流的结束被检测到,或抛出异常。
这种方法将总是读取一个整数的帧。如果数组的长度不帧的整数,最大b.length - (b.length % frameSize)
字节将被读取。
read
方法重写,继承类
InputStream
b
-缓冲区中读取数据
IOException
如果输入或输出错误发生
read(byte[], int, int)
,
read()
,
available()
public int read(byte[] b, int off, int len) throws IOException
这种方法将总是读取一个整数的帧。如果len
不指定帧的整数,最大len - (len % frameSize)
字节将被读取。
read
方法重写,继承类
InputStream
b
-缓冲区中读取数据
off
的偏移,从阵列
b
开始,该数据将被写入
len
-的最大字节数读
IOException
如果输入或输出错误发生
read(byte[])
,
read()
,
skip(long)
,
available()
public long skip(long n) throws IOException
skip
方法重写,继承类
InputStream
n
-请求的字节数被跳过
IOException
如果输入或输出错误发生
read()
,
available()
public int available() throws IOException
read
或
skip
方法的下一次调用;极限可以每次调用这些方法。根据基本流,IOException可能如果这流已被关闭。
available
方法重写,继承类
InputStream
IOException
如果输入或输出错误发生
read(byte[], int, int)
,
read(byte[])
,
read()
,
skip(long)
public void close() throws IOException
close
接口
Closeable
close
接口
AutoCloseable
close
方法重写,继承类
InputStream
IOException
如果输入或输出错误发生
public void mark(int readlimit)
mark
方法重写,继承类
InputStream
readlimit
-字节可以在标记位置无效阅读的最大数量。
reset()
,
markSupported()
public void reset() throws IOException
mark
方法调用。
reset
方法重写,继承类
InputStream
IOException
如果输入或输出错误发生。
mark(int)
,
markSupported()
public boolean markSupported()
mark
和
reset
方法。
markSupported
方法重写,继承类
InputStream
true
流支持的
mark
和
reset
方法;
false
否则
mark(int)
,
reset()
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.