There are 2 useful classes in java to manipulate dates: java.util.Date and java.util.Calendar. Another useful class to format and parse string dates is java.text.SimpleDateFormat.

How To Download a File in Java

Here is a snippet that shows how to download a file in java. The snippet is tested and works just fine: static public void download(String address, String localFileName) throws MalformedURLException , FileNotFoundException , IOException { URL url = new URL(address); OutputStream out = new BufferedOutputStream( new FileOutputStream(localFileName)); URLConnection conn = url.openConnection(); InputStream in = conn.getInputStream(); [...]

HttpClient is an apache java library that can be used to read pages over http. It can be used mainly for webpages and provide a well defined API that can handle Cookies, Sessions,… It offers support for both Get and Post methods, so it’s very useful for writing http java clients that can login and [...]

Java properties files are just simple text files that are widely used in Java to store different properties which should not be hard coded in java source files. By convention, properties files should have the .properties extension. They have a simple structure, each line defining a key/value pair. It is also possible to define larger [...]

I just took the Google Collections Library and start playing with it. I discovered a class I needed in many and many situations in the past. I’m talking about Multimap. Actually Multimap is an interface having a few classes implementing it. Along with some other interfaces it comes to fulfill a gap in the Java [...]

How To Use Ant

Ant is a build tool written in Java, intended to be used for Java build processes. Ant is used for building small and large projects as well. You can use ant not only for automation of building Java projects, but for automating any complicated and repetitive tasks. Ant is using xml files to define tasks [...]

There is a pretty common situation to use a java classes generator and to create classes based on a defined pattern. Hibernate, Castor, Jaxb are a few examples. I prefer to have those classes packed in a separate jar file. Since they are generated files it’s not a good practice to modify them, so there [...]

Java or .NET languages does not allow multiple inheritance and usually we don’t need multiple inheritance in our projects. However there are cases when inheriting from multiple classes is a necessity. There are a few tricks we can apply in order to be able to get what multiple inheritance gives us in the languages where [...]

A marker interface is a design pattern consisting in an interface with no methods declared. All the classes implementing this interface don’t have to implement a method for the interface(since it doesn’t have an interface), but we can say that the classes implementing the interfaces are marked. For example in Java we have the Serializable [...]

How to Create Jar Files from Ant

Lets take this time in consideration a real life project. Most of the time Ant is used to compile and build java projects. This means generating, compiling and building jar files. For this we are going to define severals tasks. Lets consider the we create a buid.xml file in the directory where sources are located. [...]

Books I Recommend

Blogroll