Doing the Locale - Danmark

The following illustrates how to get the Number format working with a danish locale. ''' import java.text.NumberFormat; import java.util.Currency; import java.util.Locale; public class TestLocale { public static void main(String args[]){ // Create a Locale for Danmark Locale DANMARK = new Locale("da","DK"); // get the currency instance for this locale. Currency krone = Currency.getInstance(DANMARK); // Get a Number format for the locale. NumberFormat krFormat = NumberFormat.getCurrencyInstance(DANMARK); // A symbol for the currency String symbol = krFormat....

November 12, 2008 · 1 min · Theme PaperMod

How to read a file from the JAR?

Someone just asked me this question today. And I thought might as well put it down for info. ''' public TestReadFileFromJar() throws FileNotFoundException, IOException { InputStream is = getClass().getResource(“txtData/”); read(is); } ''' In the case above txtData is placed in the jar on the root. Remmember to add the path with the “/”

October 31, 2008 · 1 min · Theme PaperMod


By using the command pattern you are seperating the operation from the invoking object. And just because of that it becomes easier to change the command without chagning the caller/s. This means that you could use Command pattern when you might have the following situation You want to parameterize objects to perform an action You want to specify, execute and queue requests at different times. Just to quickly start you need a command object, An interface will keep it easy going in this case, thus providing you with the option of extending other classes e....

October 31, 2008 · 2 min · Theme PaperMod

Implementing the adapter

Typically when implementing an interface you would have to implement all the methods that exist in that interface. A very good example is the MouseListener in the java Swing. When you need to implement more then one method where as typically you might be catching only one of them. Saying that you would also find a Mouse Adapter provided as well. Some of us use that often. And that is part of the Adapter pattern....

October 29, 2008 · 2 min · Theme PaperMod

Abstract Factory pattern

Factories have been a key pattern in building applications, its fascinatingly simple, effective and to the point. When starting to learn a design oriented approach to applications or API, I would always recommend a factory pattern as one of the key starting notes of highlight in your design. So today I am talking about the Abstract Factory pattern. Its not an “abstract” class or object that you call a pattern. But its a Factory of facotries and that is what exactly makes it so much wordingly abstract....

October 10, 2008 · 3 min · Theme PaperMod