Step 1:
First Read The Audio From MicroPhone
int cnt = targetDataLine.read( tempBuffer,0, tempBuffer.length);
Step 2:
Save data in output stream
byteArrayOutputStream.write(tempBuffer, 0, cnt);
Step 3:
Get the saved data into a byte array object.
byte audioData[]=byteArrayOutputStream.toByteArray();
Step 4:
Get an input stream on the byte array containing the data
InputStream byteArrayInputStream = new ByteArrayInputStream(audioData);
AudioFormat audioFormat = getAudioFormat();
audioInputStream =new AudioInputStream(byteArrayInputStream,audioFormat,
audioData.length/audioFormat.getFrameSize());
Step 5: Save To File
if (AudioSystem.isFileTypeSupported(AudioFileFormat.Type.AU,
audioInputStream)) {
AudioSystem.write(audioInputStream, AudioFileFormat.Type.AU, file);
}
Note :If U want Full Source Code for This One then Download the Java File
http://javasoft.phpnet.us/src/AudioRecorder.java