Thursday - December 04, 2008

OS X talking to Windows with Sockets


Found an unusual compatibility problem last week when using Sockets to communicate between OS X and Windows. The bottom line is if you have a java application on OS X that does some high volume TCP/IP socket communications to a Windows service, then you had better be using OS X Leopard to get the best performance ... about 9X better.

Posted at 08:28 AM     Read More  

Thursday - August 24, 2006

Understanding Class Paths


Class Paths can be confusing. Here is some info and links to info on that:...

Posted at 02:56 PM     Read More  

Thursday - April 06, 2006

Removing HTML tags from text


Courtesy of Zak Burke on the WebObjects dev list:

/**
* Return input string with simple HTML tags removed. The
* original string is not changed.
*
* @param s string with embedded HTML markup
* @return string with HTML tags removed.
*/
public void tagZap(String s)
{
return s.replaceAll("<[^>]+>", "");
}

Posted at 10:02 AM     Read More  

Monday - March 20, 2006

Instantiating inner classes using Class.forName


I designed a class with a number of pluggable behaviours using the strategy pattern . However this time, I decided to implement the concrete Strategy algorithm classes as inner classes of the Context class just to keep the code organized and reduce the number of tiny classes hanging around the project. Rather than use a bunch of if statements, the concrete Strategy class was simply created using its text name which came from an attribute of the Context class.

...It turns out that there is an implicit constructor for inner classes that passes the outer enclosing class as a reference .....

Posted at 11:59 AM     Read More  

Thursday - December 29, 2005

Common Programming Mistakes


Here are some simple common programming errors that the compiler will not necessarily catch. Obviously I've been caught by each one of these at one time or another!

Posted at 11:26 AM     Read More  

Thursday - May 19, 2005

Default Java CLASSPATH on OS X


Ever wonder where java looks for jars by default on OS X. Just check out the default classpath.

Posted at 11:35 AM     Read More  

Wednesday - May 18, 2005

HttpsURLConnection and HttpClient


I recently implemented java's built-in HttpsURLConnection class to process credit card transactions using a POST request over SSL. I also spun off new threads to do the processing (connect, send request, read response) since waiting for the connection and waiting for the response could get time-consuming. I expected that HttpsURLConnection would open multiple parallel HTTP connections to the service provider's host, but it did not. Then I discovered the HttpClient library from the Apache Jakarta Commons project and this nailed the problem.......

Posted at 10:01 AM     Read More  

Tuesday - January 18, 2005

The Power of Regular Expressions


Regular Expressions (RegEx for short) are a very powerful tool that can save a LOT of lines of code especially when validating input data...

Posted at 05:05 PM     Read More  


Published by