Often you need to read a file line by line. Alternatively sometimes you want to read text word by word (for example to count the occurrence of different words). The Scanner classes next() method can be used for this as shown in the following example. You can find an example of the use of the…
Read More
If you do not want to store your log4j configuration in your classes directory then you need to tell log4j where it can find it. One possibility is to configure it in your applicationContext.xml as shown here If you are running your web application as an expanded war then another option is to use a…
Read More
Ever wanted to iterate through a range of Date’s? We can use Iterator’s for looping through the elements of a Collection, but for Date’s we need to implement the Date arithmetic required. The following class shows how we can create our own Iterator implementation to easily iterate over a range of Date’s, one day at…
Read More
The readLine() method of java.io.BufferedReader class reads the next line from a text file. When it reaches the end of the file it will return null.
Read More
Lists and arrays can both be used to store ordered collections of data. Both have their strengths and weakness which we shall discuss in a later post. Previously we showed you how to generate Pascals Triangle and in that Java example we used arrays to represent each row of the triangle. The following code shows…
Read More