Code example for SourceDataLine

Methods: closeopen

	 * (in most cases if no free audio channels have been found).    
	public Java2AudioDevice() throws Exception {
		SourceDataLine sourceDataLine = getSourceDataLine(new AudioFormat(44100, 16, 2, true, false));;
	 * Gets an available audio channel (<code>SourceDataLine</code>) for specified audio stream's format. 
	 * @param format the format of the audio stream. 
	 * @return the available audio channel.  
	 * @throws LineUnavailableException raises if no available audio channels  
	 * have been found for the specified format.  
	private SourceDataLine getSourceDataLine(AudioFormat format) throws LineUnavailableException {
		DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
		if(!AudioSystem.isLineSupported(info)) {
			throw new LineUnavailableException ("Unable to find the Java 2 audio channel");