How to create XML programmatically in java / How to create XML using DOM parser in java / How to create XML file from java program

XML stands for eXtended Markup Language and is a widely used standard for transmitting information across systems mainly due to the flexibility it provides in creating the structure and data it can contain. That is, application developers can create their own structure which suits their application as there are no pre-defined tags in XML.

Scenario

Since it is a widely used standard, there arises a vital requirement to create an XML document either in the form of a String or a physical file from java application. Practical scenario is (more…)

Continue Reading

How to load property file in java / How to load property file inside a package in java / Various methods to load a property file in java

A typical java application uses some values which are not suitable to be given in code such as log generation path, output location, configuration file path, timeout values etc. Since these values vary from system to system and user to user, their values can not be pre-fixed. One user may want his logs to be generated in “myLogs” folder, another user may want the logs to be generated in “appLogs” folder. If given in code, they cannot be changed without developer intervention. Further, this change would require a re-build of code. (more…)

Continue Reading

How to calculate next working day in java / How to increment date excluding weekend in java

It may happen that you need to add some days to a particular date and the resultant date is falling on either Saturday or Sunday. So you have to calculate the next working date.

Practical Application : This is usually required in payments industry where the dates are written to files and these files are then uploaded to server but the server rejects the file if the date is a holiday. In such cases the date should be checked to be a holiday before writing it to file and incremented to a working day and then written to the file so that it is not rejected. (more…)

Continue Reading

How to sort a list of custom objects using comparable in java / How to implement Comparable in java

Suppose you have a list which contains objects of your own class rather than java’s built in classes such as java.lang.Integer, java.lang.String etc. Now you want this list to be sorted on a particular field of this class. Let’s say we have a User class which contains user details such as name, age, address etc., and we have a list of various users.
Now we want a list wherein users are listed in the order of their increasing age. That is, we need to sort the above list in the order of age. (more…)

Continue Reading
  • 1
  • 2
Close Menu