Ever since the very first time I used a properties file in Java I’ve wanted to be able to reload it upon a sysadmin request or some other circumstance without having to reload the whole application, reset the application server or use some dark proprietary Sun APIs. Well, finally in Java 1.6 we can do it!!
I recently had to load a bunch of objects into memory and then perform thousands of look-ups over that collection. Using the good old java.util.ArrayList just didn’t cut it, the contains() function is extremely slow (as you would guess of course since this implementation stores elements as they are inserted and without any aditional indexing structure).
The best tool I’ve found so far to serialize POJOs to JSON (and back again) is XStream, it’s automatic, simple and elegant, check it out.
I recently faced the problem of encrypting something in PHP and decrypting it using Java, this proved to be a little more of a challenge than what it initially seemed like.
Most web servers are missing the new MIME types needed for Office 2007 files (docx, xslx, etc.) and when you server one of this files from your web application the users browser typically tries to open them as ZIP files.
Download a file using Java from a URL should be a simple task, well it is :P. If you just don’t want to think too much about it here is a sample method to do it.
If you ever tried to create a JAR file from Java code using JarOutputStream on a Windows platform you might have become as frustrated as me. I ran into two problems and since they took a nice part of my sleep time I’ve decided to share them and the solutions I found.
Check it out at http://www.styledisplay.com/mootoolsdatepicker/, it’s quite simple to use and looks great.
Need to read a file into a byte array in memory, here’s a simple code sample.
The folks at IBM have a nice API to use i5/OS (AS400) stuff from Java code. Check it out at http://www-03.ibm.com/systems/i/software/toolbox/index.html.
What I particularly find very useful and have used often is to validate user names and passwords with the AS400 authentication services. The following code validates a userName and password.