Hi I am trying to write an application that will play morse code. I just wanted to know if there was a default system sound in java like some beep, or do I have to download some sound file from the internet?
You can:
Print the ASCII bell character to the console (will emit a beep sound):
public class DoBeep {
public static main(String args[]) {
System.out.print("\007"); // bell ASCII char
System.out.flush();
}
}
Use the beep()
method that will use the buzzer on the motherboard:
import java.awt.*;
public class DoBeep {
public static void main(String args[]) {
Toolkit.getDefaultToolkit().beep();
}
}