I’m making Braid in Java. If you rewind the time, the sound plays backward. How to play a WAV file backwards? Maybe with a stream with something like previous()? On the site of Braid can you see what I mean. Update: Solved! See my own post. Answer I solved it by myself And then:
How to wait for a number of threads to complete?
What is a way to simply wait for all threaded process to finish? For example, let’s say I have: How do I alter this so the main() method pauses at the comment until all threads’ run() methods exit? Thanks! Answer You put all threads in an array, start them all, and then have a loop Each join will …
Is *this* really the best way to start a second JVM from Java code?
This is a followup to my own previous question and I’m kind of embarassed to ask this… But anyway: how would you start a second JVM from a standalone Java program in a system-independent way? And without relying on for instance an env variable like JAVA_HOME as that might point to a different JRE …
Most efficient way to create InputStream from OutputStream
This page: http://blog.ostermiller.org/convert-java-outputstream-inputstream describes how to create an InputStream from OutputStream: Other alternatives are to use PipedStreams and new threads which is cumbersome. I do not like the idea of copying many megabytes to new in memory byte array. Is there a librar…
Modifying a file inside a jar
I would like to modify a file inside my jar. Is it possible to do this without extracting and re jarring, from within my application? File i want to modify are configuration files, mostly xml based. The reason i am interested in not un jarring is that the application is wrapped with launch4j if i unjar it i c…
How do I find out if first character of a string is a number?
In Java is there a way to find out if first character of a string is a number? One way is and do the above all the way till 9, but that seems very inefficient. Answer Note that this will allow any Unicode digit, not just 0-9. You might prefer: Or the slower regex solutions: However, with any of these
Using Prepared Statements to set Table Name
I’m trying to use prepared statements to set a table name to select data from, but I keep getting an error when I execute the query. The error and sample code is displayed below. Any thoughts on what might be causing this? Answer A table name can’t be used as a parameter. It must be hard coded. So…
How to encrypt String in Java
What I need is to encrypt string which will show up in 2D barcode(PDF-417) so when someone get an idea to scan it will get nothing readable. Other requirements: should not be complicated it should not consist of RSA, PKI infrastructure, key pairs, etc. It must be simple enough to get rid of the people snoopin…
Shrinking an ArrayList to a new size
Do I really need to implement it myself? Answer Create a sublist with the range of elements you wish to remove and then call clear on the returned list. This approach is mentioned as an idiom in the documentation for both List and ArrayList. Here’s a fully unit tested code example!
How do I print the class structures in a jar file using the javap tool?
I want to list the methods of the class files in the jar using the javap tool. How do I do it so that it lists the methods and members of all the class files in the jar. Right now I am able to do it for just one class at a time. I am expecting something like if I