APIdia Launch Partner
Top Description Constructors Methods
javax.sound.sampled.spi

public abstract Class AudioFileWriter

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.media.sound.SunFileWriter, com.sun.media.sound.WaveFloatFileWriter
Imports
java.io.File, .IOException, .OutputStream, java.util.Arrays, javax.sound.sampled.AudioInputStream, .AudioSystem

Provider for audio file writing services. Classes providing concrete implementations can write one or more types of audio file from an audio stream.
Author
Kara Kytle
Since
1.3

Constructor Summary

AccessConstructor and Description
protected
AudioFileWriter()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract AudioFileFormat.Type[]

Returns:

array of file types. If no file types are supported, an array of length 0 is returned.
getAudioFileTypes
()

Obtains the file types for which file writing support is provided by this audio file writer.

public abstract AudioFileFormat.Type[]

Returns:

array of file types. If no file types are supported, an array of length 0 is returned.
getAudioFileTypes
(AudioInputStream
the audio input stream for which audio file type support is queried
stream
)

Obtains the file types that this audio file writer can write from the audio input stream specified.

public boolean

Returns:

true if the file type is supported, otherwise false
isFileTypeSupported
(final AudioFileFormat.Type
the file type for which write capabilities are queried
fileType
)

Indicates whether file writing support for the specified file type is provided by this audio file writer.

public boolean

Returns:

true if the file type is supported for this audio input stream, otherwise false
isFileTypeSupported
(final AudioFileFormat.Type
file type for which write capabilities are queried
fileType
,
final AudioInputStream
for which file writing support is queried
stream
)

Indicates whether an audio file of the type specified can be written from the audio input stream indicated.

public abstract int

Returns:

the number of bytes written to the output stream
write
(AudioInputStream
the audio input stream containing audio data to be written to the output stream
stream
,
AudioFileFormat.Type
file type to be written to the output stream
fileType
,
OutputStream
stream to which the file data should be written
out
)

Writes a stream of bytes representing an audio file of the file type indicated to the output stream provided.

public abstract int

Returns:

the number of bytes written to the file
write
(AudioInputStream
the audio input stream containing audio data to be written to the file
stream
,
AudioFileFormat.Type
file type to be written to the file
fileType
,
File
external file to which the file data should be written
out
)

Writes a stream of bytes representing an audio file of the file format indicated to the external file provided.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AudioFileWriterback to summary
protected AudioFileWriter()

Constructor for subclasses to call.

Method Detail

getAudioFileTypesback to summary
public abstract AudioFileFormat.Type[] getAudioFileTypes()

Obtains the file types for which file writing support is provided by this audio file writer.

Returns:AudioFileFormat.Type[]

array of file types. If no file types are supported, an array of length 0 is returned.

getAudioFileTypesback to summary
public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream)

Obtains the file types that this audio file writer can write from the audio input stream specified.

Parameters
stream:AudioInputStream

the audio input stream for which audio file type support is queried

Returns:AudioFileFormat.Type[]

array of file types. If no file types are supported, an array of length 0 is returned.

Exceptions
NullPointerException:
if stream is null
isFileTypeSupportedback to summary
public boolean isFileTypeSupported(final AudioFileFormat.Type fileType)

Indicates whether file writing support for the specified file type is provided by this audio file writer.

Parameters
fileType:AudioFileFormat.Type

the file type for which write capabilities are queried

Returns:boolean

true if the file type is supported, otherwise false

Exceptions
NullPointerException:
if fileType is null
isFileTypeSupportedback to summary
public boolean isFileTypeSupported(final AudioFileFormat.Type fileType, final AudioInputStream stream)

Indicates whether an audio file of the type specified can be written from the audio input stream indicated.

Parameters
fileType:AudioFileFormat.Type

file type for which write capabilities are queried

stream:AudioInputStream

for which file writing support is queried

Returns:boolean

true if the file type is supported for this audio input stream, otherwise false

Exceptions
NullPointerException:
if fileType or stream are null
writeback to summary
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, OutputStream out) throws IOException

Writes a stream of bytes representing an audio file of the file type indicated to the output stream provided. Some file types require that the length be written into the file header, and cannot be written from start to finish unless the length is known in advance. An attempt to write such a file type will fail with an IOException if the length in the audio file format is AudioSystem#NOT_SPECIFIED.

Parameters
stream:AudioInputStream

the audio input stream containing audio data to be written to the output stream

fileType:AudioFileFormat.Type

file type to be written to the output stream

out:OutputStream

stream to which the file data should be written

Returns:int

the number of bytes written to the output stream

Exceptions
IOException:
if an I/O exception occurs
IllegalArgumentException:
if the file type is not supported by the system
NullPointerException:
if stream or fileType or out are null
See Also
isFileTypeSupported(Type, AudioInputStream), getAudioFileTypes
writeback to summary
public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException

Writes a stream of bytes representing an audio file of the file format indicated to the external file provided.

Parameters
stream:AudioInputStream

the audio input stream containing audio data to be written to the file

fileType:AudioFileFormat.Type

file type to be written to the file

out:File

external file to which the file data should be written

Returns:int

the number of bytes written to the file

Exceptions
IOException:
if an I/O exception occurs
IllegalArgumentException:
if the file format is not supported by the system
NullPointerException:
if stream or fileType or out are null
See Also
isFileTypeSupported(Type, AudioInputStream), getAudioFileTypes