generate beep sound in JavaThis simple snippet shows how to produce the Beep Sound in Java using the AWT Toolkit. The key thing here is is the delay introduced in the subsequent beeps. Changing the delay between beeps, you can create different sound patterns or rhythms. This beep can be used in games development or signalling the user for some input errors or for some sort of notification.
package com.livrona.snippets.audio;

/**
 * This snippet shows how to produce series of Beep sounds.
 * 
 * @author mvohra
 * 
 */
public class BeepProducer {

	/**
	 * main(.) method
	 * @param args
	 */
	public static void main(String[] args) {

		int beepCount = 10;
		for (int i = 0; i < beepCount; ++i) {
			System.out.println("Beep : " + i);
			// Ring the bell again using the Toolkit 
			java.awt.Toolkit.getDefaultToolkit().beep();
			try {
				Thread.sleep(1000); // introduce delay
			} catch (InterruptedException e) {
			}
		}

	} // end of main( )
} // end of Beep Producer