If you're simply needing to convert a file(as opposed to a stream), you may
want to use the FLAC_FileEncoder class.
For applications using the javax.sound API, this library includes basic support.
FLACFileWriter provides the implementation of
javax.sound.sampled.spi.AudioFileWriter. After installing a release jar in the
appropriate location, the FLAC encoder should be available for use by any application
which makes use of the sound api for transcoding purposes. Use this if you need basic
encoding support(with default configuration), and have a
javax.sound.sampled.AudioInputStream as your source.
The remaining example is for those who need more control over the encoding
process, including supplying a non-default EncodingConfiguration object, or
for whom the prior methods are not otherwise suitable. For direct, low-level
access, an application should primarily use the classes FLACEncoder,
EncodingConfiguration, StreamConfiguration, and FLACOutputStream.
1) Set StreamConfiguration to appropriate values. After a stream is opened, this must not be altered until the stream is closed.
2) Set FLACOutputStream, object to write results to.
3) Open FLAC Stream
4) Set EncodingConfiguration(if defaults are insufficient).
5) Add samples to encoder
6) Encode Samples
7) Close stream
(note: steps 4,5, and 6 may be done repeatedly, in any order. However, see related method documentation for info on concurrent use)