Last active
September 18, 2021 08:37
-
-
Save philard/b92214e230e3c1de5f6d65b952b3de14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String className = (this != null) ? this.getClass().getSimpleName() : ""; | |
int wavFilesCount = new java.io.File("sounds").listFiles().length; | |
int clipIndex = (className.hashCode() & 0x7FFFFFFF) % wavFilesCount; | |
javax.sound.sampled.Clip clip = javax.sound.sampled.AudioSystem.getClip(); | |
java.io.File wavFile = new java.io.File("sounds" + java.io.File.separator + "sound" + clipIndex + ".wav"); | |
javax.sound.sampled.AudioInputStream audio = javax.sound.sampled.AudioSystem.getAudioInputStream(wavFile); | |
clip.open(audio); | |
clip.start(); | |
String metaMessage = new java.util.Date().toString() + " clip:" + clipIndex + " class:" + className + System.lineSeparator(); | |
java.io.PrintWriter writer = new java.io.PrintWriter(new java.io.File("stack-trace.log")); | |
writer.append(metaMessage); | |
new Throwable().printStackTrace(writer); | |
writer.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Find your JVM's base directory (.../tomcat/bin) and extract the sounds zip there. Then add the script to your Idea's breakpoints under "Evaluate and log". Sounds based on the class name will play. Latest stack trace is written to "stack-trace.log".