The AudioSystem class acts as the entry point to the sampled-audio system resources. This class lets you query and access the mixers that are installed on the system. AudioSystem includes a number of methods for converting audio data between different formats, and for translating between audio files and streams. It also provides a method for obtaining a Line directly from the AudioSystem without dealing explicitly with mixers.

Properties can be used to specify the default mixer for specific line types. Both system properties and a properties file are considered. In the Sun reference implementation, the properties file is "lib/sound.properties" in the JRE directory. If a property exists both as a system property and in the properties file, the system property takes precedence. If none is specified, a suitable default is chosen among the available devices. The syntax of the properties file is specified in Properties.load . The following table lists the available property keys and which methods consider them:
Property Key Interface Affected Method(s)
javax.sound.sampled.Clip Clip #getLine , #getClip
javax.sound.sampled.Port Port #getLine
javax.sound.sampled.SourceDataLine SourceDataLine #getLine , #getSourceDataLine
javax.sound.sampled.TargetDataLine TargetDataLine #getLine , #getTargetDataLine
The property value consists of the provider class name and the mixer name, separated by the hash mark ("#"). The provider class name is the fully-qualified name of a concrete mixer provider class. The mixer name is matched against the String returned by the getName method of Mixer.Info. Either the class name, or the mixer name may be omitted. If only the class name is specified, the trailing hash mark is optional.

If the provider class is specified, and it can be successully retrieved from the installed providers, the list of Mixer.Info objects is retrieved from the provider. Otherwise, or when these mixers do not provide a subsequent match, the list is retrieved from #getMixerInfo to contain all available Mixer.Info objects.

If a mixer name is specified, the resulting list of Mixer.Info objects is searched: the first one with a matching name, and whose Mixer provides the respective line interface, will be returned. If no matching Mixer.Info object is found, or the mixer name is not specified, the first mixer from the resulting list, which provides the respective line interface, will be returned. For example, the property javax.sound.sampled.Clip with a value "com.sun.media.sound.MixerProvider#SunClip" will have the following consequences when getLine is called requesting a Clip instance: if the class com.sun.media.sound.MixerProvider exists in the list of installed mixer providers, the first Clip from the first mixer with name "SunClip" will be returned. If it cannot be found, the first Clip from the first mixer of the specified provider will be returned, regardless of name. If there is none, the first Clip from the first Mixer with name "SunClip" in the list of all mixers (as returned by getMixerInfo) will be returned, or, if not found, the first Clip of the first Mixerthat can be found in the list of all mixers is returned. If that fails, too, an IllegalArgumentException is thrown.

@author
Kara Kytle
@author
Florian Bomers
@author
Matthias Pfisterer
@author
Kevin P. Smith
@version
1.81, 04/07/14
@since
1.3
An integer that stands for an unknown numeric value. This value is appropriate only for signed quantities that do not normally take negative values. Examples include file sizes, frame sizes, buffer sizes, and sample rates. A number of Java Sound constructors accept a value of NOT_SPECIFIED for such parameters. Other methods may also accept or return this value, as documented.
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
objthe reference object with which to compare.
Return
true if this object is the same as the obj argument; false otherwise.
Obtains the audio file format of the specified File. The File must point to valid audio file data.
Parameters
filethe File from which file format information should be extracted
Return
an AudioFileFormat object describing the audio file format
Throws
UnsupportedAudioFileExceptionif the File does not point to valid audio file data recognized by the system
IOExceptionif an I/O exception occurs
Obtains the audio file format of the provided input stream. The stream must point to valid audio file data. The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream's read pointer to its original position. If the input stream does not support these operations, this method may fail with an IOException.
Parameters
streamthe input stream from which file format information should be extracted
Return
an AudioFileFormat object describing the stream's audio file format
Throws
UnsupportedAudioFileExceptionif the stream does not point to valid audio file data recognized by the system
IOExceptionif an input/output exception occurs
Obtains the audio file format of the specified URL. The URL must point to valid audio file data.
Parameters
urlthe URL from which file format information should be extracted
Return
an AudioFileFormat object describing the audio file format
Throws
UnsupportedAudioFileExceptionif the URL does not point to valid audio file data recognized by the system
IOExceptionif an input/output exception occurs
Obtains the file types for which file writing support is provided by the system.
Return
array of unique file types. If no file types are supported, an array of length 0 is returned.
Obtains the file types that the system can write from the audio input stream specified.
Parameters
streamthe audio input stream for which audio file type support is queried
Return
array of file types. If no file types are supported, an array of length 0 is returned.
Obtains an audio input stream of the indicated encoding, by converting the provided audio input stream.
Parameters
targetEncodingthe desired encoding after conversion
sourceStreamthe stream to be converted
Return
an audio input stream of the indicated encoding
Throws
IllegalArgumentExceptionif the conversion is not supported
Obtains an audio input stream of the indicated format, by converting the provided audio input stream.
Parameters
targetFormatthe desired audio format after conversion
sourceStreamthe stream to be converted
Return
an audio input stream of the indicated format
Throws
IllegalArgumentExceptionif the conversion is not supported #see #getTargetEncodings(AudioFormat)
Obtains an audio input stream from the provided File. The File must point to valid audio file data.
Parameters
filethe File for which the AudioInputStream should be constructed
Return
an AudioInputStream object based on the audio file data pointed to by the File
Throws
UnsupportedAudioFileExceptionif the File does not point to valid audio file data recognized by the system
IOExceptionif an I/O exception occurs
Obtains an audio input stream from the provided input stream. The stream must point to valid audio file data. The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream's read pointer to its original position. If the input stream does not support these operation, this method may fail with an IOException.
Parameters
streamthe input stream from which the AudioInputStream should be constructed
Return
an AudioInputStream object based on the audio file data contained in the input stream.
Throws
UnsupportedAudioFileExceptionif the stream does not point to valid audio file data recognized by the system
IOExceptionif an I/O exception occurs
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.
Parameters
urlthe URL for which the AudioInputStream should be constructed
Return
an AudioInputStream object based on the audio file data pointed to by the URL
Throws
UnsupportedAudioFileExceptionif the URL does not point to valid audio file data recognized by the system
IOExceptionif an I/O exception occurs
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
Obtains a clip that can be used for playing back an audio file or an audio stream. The returned clip will be provided by the default system mixer, or, if not possible, by any other mixer installed in the system that supports a Clip object.

The returned clip must be opened with the open(AudioFormat) or open(AudioInputStream) method.

This is a high-level method that uses getMixer and internally.

If the system property javax.sound.sampled.Clip is defined or it is defined in the file "sound.properties", it is used to retrieve the default clip. For details, refer to the class description .

Return
the desired clip object
Throws
LineUnavailableExceptionif a clip object is not available due to resource restrictions
SecurityExceptionif a clip object is not available due to security restrictions
IllegalArgumentExceptionif the system does not support at least one clip instance through any installed mixer
@since
1.5
Obtains a clip from the specified mixer that can be used for playing back an audio file or an audio stream.

The returned clip must be opened with the open(AudioFormat) or open(AudioInputStream) method.

This is a high-level method that uses getMixer and internally.

Parameters
mixerInfoa Mixer.Info object representing the desired mixer, or null for the system default mixer
Return
a clip object from the specified mixer
Throws
LineUnavailableExceptionif a clip is not available from this mixer due to resource restrictions
SecurityExceptionif a clip is not available from this mixer due to security restrictions
IllegalArgumentExceptionif the system does not support at least one clip through the specified mixer
@since
1.5
See Also
Obtains a line that matches the description in the specified Line.Info object.

If a DataLine is requested, and info is an instance of DataLine.Info specifying at least one fully qualified audio format, the last one will be used as the default format of the returned DataLine.

If system properties javax.sound.sampled.Clip, javax.sound.sampled.Port, javax.sound.sampled.SourceDataLine and javax.sound.sampled.TargetDataLine are defined or they are defined in the file "sound.properties", they are used to retrieve default lines. For details, refer to the class description . If the respective property is not set, or the mixer requested in the property is not installed or does not provide the requested line, all installed mixers are queried for the requested line type. A Line will be returned from the first mixer providing the requested line type.

Parameters
infoa Line.Info object describing the desired kind of line
Return
a line of the requested kind
Throws
LineUnavailableExceptionif a matching line is not available due to resource restrictions
SecurityExceptionif a matching line is not available due to security restrictions
IllegalArgumentExceptionif the system does not support at least one line matching the specified Line.Info object through any installed mixer
Obtains the requested audio mixer.
Parameters
infoa Mixer.Info object representing the desired mixer, or null for the system default mixer
Return
the requested mixer
Throws
SecurityExceptionif the requested mixer is unavailable because of security restrictions
IllegalArgumentExceptionif the info object does not represent a mixer installed on the system
See Also
Obtains an array of mixer info objects that represents the set of audio mixers that are currently installed on the system.
Return
an array of info objects for the currently installed mixers. If no mixers are available on the system, an array of length 0 is returned.
See Also
Obtains a source data line that can be used for playing back audio data in the format specified by the AudioFormat object. The returned line will be provided by the default system mixer, or, if not possible, by any other mixer installed in the system that supports a matching SourceDataLine object.

The returned line should be opened with the open(AudioFormat) or open(AudioFormat, int) method.

This is a high-level method that uses getMixer and internally.

The returned SourceDataLine's default audio format will be initialized with format.

If the system property javax.sound.sampled.SourceDataLine is defined or it is defined in the file "sound.properties", it is used to retrieve the default source data line. For details, refer to the class description .

Parameters
formatan AudioFormat object specifying the supported audio format of the returned line, or null for any audio format
Return
the desired SourceDataLine object
Throws
LineUnavailableExceptionif a matching source data line is not available due to resource restrictions
SecurityExceptionif a matching source data line is not available due to security restrictions
IllegalArgumentExceptionif the system does not support at least one source data line supporting the specified audio format through any installed mixer
@since
1.5
Obtains a source data line that can be used for playing back audio data in the format specified by the AudioFormat object, provided by the mixer specified by the Mixer.Info object.

The returned line should be opened with the open(AudioFormat) or open(AudioFormat, int) method.

This is a high-level method that uses getMixer and internally.

The returned SourceDataLine's default audio format will be initialized with format.

Parameters
formatan AudioFormat object specifying the supported audio format of the returned line, or null for any audio format
mixerinfoa Mixer.Info object representing the desired mixer, or null for the system default mixer
Return
the desired SourceDataLine object
Throws
LineUnavailableExceptionif a matching source data line is not available from the specified mixer due to resource restrictions
SecurityExceptionif a matching source data line is not available from the specified mixer due to security restrictions
IllegalArgumentExceptionif the specified mixer does not support at least one source data line supporting the specified audio format
@since
1.5
Obtains information about all source lines of a particular type that are supported by the installed mixers.
Parameters
infoa Line.Info object that specifies the kind of lines about which information is requested
Return
an array of Line.Info objects describing source lines matching the type requested. If no matching source lines are supported, an array of length 0 is returned.
Obtains a target data line that can be used for recording audio data in the format specified by the AudioFormat object. The returned line will be provided by the default system mixer, or, if not possible, by any other mixer installed in the system that supports a matching TargetDataLine object.

The returned line should be opened with the open(AudioFormat) or open(AudioFormat, int) method.

This is a high-level method that uses getMixer and internally.

The returned TargetDataLine's default audio format will be initialized with format.

Parameters
formatan AudioFormat object specifying the supported audio format of the returned line, or null for any audio format
Return
the desired TargetDataLine object
Throws
LineUnavailableExceptionif a matching target data line is not available due to resource restrictions
SecurityExceptionif a matching target data line is not available due to security restrictions
IllegalArgumentExceptionif the system does not support at least one target data line supporting the specified audio format through any installed mixer
@since
1.5
Obtains a target data line that can be used for recording audio data in the format specified by the AudioFormat object, provided by the mixer specified by the Mixer.Info object.

The returned line should be opened with the open(AudioFormat) or open(AudioFormat, int) method.

This is a high-level method that uses getMixer and internally.

The returned TargetDataLine's default audio format will be initialized with format.

If the system property javax.sound.sampled.TargetDataLine is defined or it is defined in the file "sound.properties", it is used to retrieve the default target data line. For details, refer to the class description .

Parameters
formatan AudioFormat object specifying the supported audio format of the returned line, or null for any audio format
mixerinfoa Mixer.Info object representing the desired mixer, or null for the system default mixer
Return
the desired TargetDataLine object
Throws
LineUnavailableExceptionif a matching target data line is not available from the specified mixer due to resource restrictions
SecurityExceptionif a matching target data line is not available from the specified mixer due to security restrictions
IllegalArgumentExceptionif the specified mixer does not support at least one target data line supporting the specified audio format
@since
1.5
Obtains the encodings that the system can obtain from an audio input stream with the specified encoding using the set of installed format converters.
Parameters
sourceEncodingthe encoding for which conversion support is queried
Return
array of encodings. If sourceEncodingis not supported, an array of length 0 is returned. Otherwise, the array will have a length of at least 1, representing sourceEncoding (no conversion).
Obtains the encodings that the system can obtain from an audio input stream with the specified format using the set of installed format converters.
Parameters
sourceFormatthe audio format for which conversion is queried
Return
array of encodings. If sourceFormatis not supported, an array of length 0 is returned. Otherwise, the array will have a length of at least 1, representing the encoding of sourceFormat (no conversion).
Obtains the formats that have a particular encoding and that the system can obtain from a stream of the specified format using the set of installed format converters.
Parameters
targetEncodingthe desired encoding after conversion
sourceFormatthe audio format before conversion
Return
array of formats. If no formats of the specified encoding are supported, an array of length 0 is returned.
Obtains information about all target lines of a particular type that are supported by the installed mixers.
Parameters
infoa Line.Info object that specifies the kind of lines about which information is requested
Return
an array of Line.Info objects describing target lines matching the type requested. If no matching target lines are supported, an array of length 0 is returned.
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Return
a hash code value for this object.
Indicates whether an audio input stream of the specified encoding can be obtained from an audio input stream that has the specified format.
Parameters
targetEncodingthe desired encoding after conversion
sourceFormatthe audio format before conversion
Return
true if the conversion is supported, otherwise false
Indicates whether an audio input stream of a specified format can be obtained from an audio input stream of another specified format.
Parameters
targetFormatthe desired audio format after conversion
sourceFormatthe audio format before conversion
Return
true if the conversion is supported, otherwise false
Indicates whether file writing support for the specified file type is provided by the system.
Parameters
fileTypethe file type for which write capabilities are queried
Return
true if the file type is supported, otherwise false
Indicates whether an audio file of the specified file type can be written from the indicated audio input stream.
Parameters
fileTypethe file type for which write capabilities are queried
streamthe stream for which file-writing support is queried
Return
true if the file type is supported for this audio input stream, otherwise false
Indicates whether the system supports any lines that match the specified Line.Info object. A line is supported if any installed mixer supports it.
Parameters
infoa Line.Info object describing the line for which support is queried
Return
true if at least one matching line is supported, otherwise false
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 
Return
a string representation of the object.
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Writes a stream of bytes representing an audio file of the specified file type to the external file provided.
Parameters
streamthe audio input stream containing audio data to be written to the file
fileTypethe kind of audio file to write
outthe external file to which the file data should be written
Return
the number of bytes written to the file
Throws
IOExceptionif an I/O exception occurs
IllegalArgumentExceptionif the file type is not supported by the system
Writes a stream of bytes representing an audio file of the specified file type to the output stream provided. Some file types require that the length be written into the file header; such files cannot be written from start to finish unless the length is known in advance. An attempt to write a file of such a type will fail with an IOException if the length in the audio file type is AudioSystem.NOT_SPECIFIED.
Parameters
streamthe audio input stream containing audio data to be written to the file
fileTypethe kind of audio file to write
outthe stream to which the file data should be written
Return
the number of bytes written to the output stream
Throws
IOExceptionif an input/output exception occurs
IllegalArgumentExceptionif the file type is not supported by the system