public interface Line extends AutoCloseable
Line接口表示单声道或多声道音频馈送。 
       线是数字音频“流水线”的一个元素,例如混频器,输入或输出端口,或进入或离开混频器的数据路径。 
        线可以有控制,如增益,平移和混响。 控件本身就是扩展基础ControlLine接口提供两种访问方法来获取线路的控件: getControlsgetControl
 线条在不同时期存在于各种状态。 当一条线路打开时,它将为其自身保留系统资源,当它关闭时,这些资源被释放用于其他对象或应用程序。 isOpen()SourceDataLine.writeTargetDataLine.readSourceDataLine.writeTargetDataLine.read
 每当线路状态发生变化时,您可以注册一个对象来接收通知。 该对象必须实现LineListenerupdateDataLine ,启动和停止),将调用此方法。 
 可以注册一个对象来监听多行。 它接收在其事件update方法将指定哪些线创建的事件,这是什么类型的事件( OPEN , CLOSE , START ,或STOP )许多样品如何帧的行,并在事件发生的时间已经处理。 
某些行操作(如打开和关闭)可以在线路是共享音频资源时由非特权代码调用时生成安全异常。
LineEvent 
       | Modifier and Type | Interface and Description | 
|---|---|
| static class  | Line.InfoLine.Info对象包含有关行的信息。 | 
| Modifier and Type | Method and Description | 
|---|---|
| void | addLineListener(LineListener listener)
              在此行添加一个侦听器。 
             | 
| void | close()
              关闭该行,表示可以释放该行所使用的任何系统资源。 
             | 
| Control | getControl(Control.Type control)
              获取指定类型的控件,如果有的话。 
             | 
| Control[] | getControls()
              获取与此行相关联的一组控件。 
             | 
| Line.Info | getLineInfo()
              获取描述此行的 
              Line.Info对象。 | 
| boolean | isControlSupported(Control.Type control)
              指示线路是否支持指定类型的控制。 
             | 
| boolean | isOpen()
              表示线路是否打开,这意味着它已经预留了系统资源并且可以运行,尽管它可能当前没有播放或捕获声音。 
             | 
| void | open()
              打开该行,表明它应该获取任何所需的系统资源并运行。 
             | 
| void | removeLineListener(LineListener listener)
              从此行的侦听器列表中删除指定的侦听器。 
             | 
Line.Info getLineInfo()
Line.Info对象。 
          void open() throws LineUnavailableException
OPEN事件将调度到该行的监听器。 
            请注意,一旦关闭,一些行不能重新打开。 尝试重新打开此行将始终导致LineUnavailableException 。 
 某些类型的行具有可能影响资源分配的可配置属性。 例如, DataLine必须以特定格式和缓冲区大小打开。 这样的行应该提供一种用于配置这些属性的机制,例如允许应用程序指定所需设置的open方法或方法。 
 此方法不使用参数,并打开与当前设置的行。 对于SourceDataLineTargetDataLineClipopen种提供的方法Clip接口将数据加载到Clip 。 
 对于DataLine ,如果用于检索该行的DataLine.Info对象指定了至少一个完全限定的音频格式,则最后一个将被用作默认格式。 
IllegalArgumentException - 如果在Clip实例上调用此方法。 
           LineUnavailableException - 如果由于资源限制,该行无法打开。 
           SecurityException - 如果由于安全限制,该行无法打开。 
           close() , isOpen() , LineEvent , DataLine , Clip.open(AudioFormat, byte[], int, int) , Clip.open(AudioInputStream) 
           void close()
CLOSE事件将发送到该行的监听器。 
          close在界面 
            AutoCloseable 
           SecurityException - 如果线路由于安全限制而无法关闭。 
           open() , isOpen() , LineEvent 
           boolean isOpen()
Control[] getControls()
getControl(javax.sound.sampled.Control.Type) 
           boolean isControlSupported(Control.Type control)
control - 查询支持的控件的类型 
           true如果支持指定类型的至少一个控件,否则 
            false 。 
           Control getControl(Control.Type control)
control - 请求的控件的类型 
           IllegalArgumentException - 如果不支持指定类型的控件 
           getControls() , 
            isControlSupported(Control.Type control) 
           void addLineListener(LineListener listener)
update()方法将使用描述更改的LineEvent对象进行调用。 
          listener - 作为监听器添加到此行的对象 
           removeLineListener(javax.sound.sampled.LineListener) , LineListener.update(javax.sound.sampled.LineEvent) , LineEvent 
           void removeLineListener(LineListener listener)
listener - 要删除的监听器 
           addLineListener(javax.sound.sampled.LineListener) 
            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.