API Overview API Index Package Overview Direct link to this page
JDK 1.6
  javax.sound.sampled.spi. AudioFileWriter View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130

/*
 * @(#)AudioFileWriter.java	1.25 05/11/17
 *
 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

package javax.sound.sampled.spi;

import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.sound.sampled.AudioFileFormat;
import javax.sound.sampled.AudioInputStream;


/**
 * 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
 * @version 1.25, 05/11/17
 * @since 1.3
 */
public abstract class AudioFileWriter {

    /**
     * Obtains the file types for which file writing support is provided by this
     * audio file writer.
     * @return array of file types.  If no file types are supported,
     * an array of length 0 is returned.
     */
    public abstract AudioFileFormat.Type[] getAudioFileTypes();


    /**
     * Indicates whether file writing support for the specified file type is provided
     * by this audio file writer.
     * @param fileType the file type for which write capabilities are queried
     * @return <code>true</code> if the file type is supported,
     * otherwise <code>false</code>
     */
    public boolean isFileTypeSupported(AudioFileFormat.Type fileType) {

	AudioFileFormat.Type types[] = getAudioFileTypes();

	for(int i=0; i<types.length; i++) {
	    if( fileType.equals( types[i] ) ) {
		return true;
	    }
	}
	return false;
    }


    /**
     * Obtains the file types that this audio file writer can write from the
     * audio input stream specified.
     * @param stream the 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.
     */
    public abstract AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream);


    /**
     * Indicates whether an audio file of the type specified can be written
     * from the audio input stream indicated.
     * @param fileType file type for which write capabilities are queried
     * @param stream for which file writing support is queried
     * @return <code>true</code> if the file type is supported for this audio input stream,
     * otherwise <code>false</code>
     */
    public boolean isFileTypeSupported(AudioFileFormat.Type fileType, AudioInputStream stream) {

	AudioFileFormat.Type types[] = getAudioFileTypes( stream );

	for(int i=0; i<types.length; i++) {
	    if( fileType.equals( types[i] ) ) {
		return true;
	    }
	}
	return false;
    }


    /**
     * 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
     * {@link javax.sound.sampled.AudioSystem#NOT_SPECIFIED AudioSystem.NOT_SPECIFIED}.
     * @param stream the audio input stream containing audio data to be
     * written to the output stream
     * @param fileType file type to be written to the output stream
     * @param out stream to which the file data should be written
     * @return the number of bytes written to the output stream
     * @throws IOException if an I/O exception occurs
     * @throws IllegalArgumentException if the file type is not supported by
     * the system
     * @see #isFileTypeSupported(AudioFileFormat.Type, AudioInputStream)
     * @see #getAudioFileTypes
     */
    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 format
     * indicated to the external file provided.
     * @param stream the audio input stream containing audio data to be
     * written to the file
     * @param fileType file type to be written to the file
     * @param out external file to which the file data should be written
     * @return the number of bytes written to the file
     * @throws IOException if an I/O exception occurs
     * @throws IllegalArgumentException if the file format is not supported by
     * the system
     * @see #isFileTypeSupported
     * @see #getAudioFileTypes
     */
    public abstract int write(AudioInputStream stream, AudioFileFormat.Type fileType, File out) throws IOException;

    
}

Generated By: JavaOnTracks Doclet 0.1.4     ©Thibaut Colar