How to make a connection using Proxy in java

This Post will explain you, What is Proxy and  How to connect to a Proxy using a java program. A full example with detailed explanation ensures you to get a complete idea of the proxy concept. Sometimes we may need to connect to an URL or some resource from your application or java program via a proxy. Before showing you the code first let me explain you what is proxy? It’s purpose and how...

Encryption and Decryption using AES algorithm in Java

AESUtility.java package com.americanexpress.gpzn.services.processservice.galaxy.v1.util; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; import javax.crypto.KeyGenerator; import javax.crypto.NoSuchPaddingException; import...

How to copy contents of a database table to another in java

Suppose say abc is a advertising company and it allows its’ visitors to test their advertisements in test environments before making them live. We need to implement such a requirement by copying the the records of one table into the another table under 2 different databases. I have written the java code to copy contents of a database table to another. If ever you have some requirement or...

Encapsulation in Java with Example

Encapsulation is a basic principle of Java. Let me explain you encapsulation with a simple example.After reading the concept completely, I’m pretty sure you will never need to look back again to learn encapsulation concept. Encapsulation ensures to hide the implementation details of a class to the other classes. Basic elements in a class are instance variables and member functions. Let us assume...

Introduction: Basic understanding of XPath and its related concepts

Introduction to XPath: Full form of XPath is XML Path. It is a query language designed to traverse through an xml document and select the required nodes using XPath Expressions and XPath functions, which I will discuss in the next chapters. XPath is a World Wide Web consortium (w3c) recommendation and the latest specification is Xpath 2.0. This specification is designed to be referenced...

How to convert a XML file into a csv file using java?

We Used a property file to get xpath expressions of the corresponding mapped elements in XML file. If you got an doubt regarding property file, you can go throw my tutorial about how to read a property file. Here I converted an XML file into a Document Object and I have used the configured Xpath Expressions in the property file to retrieve the values from XML document. XMLToCSVMappings.java...

How to Read a Property File into Hash Map in Java

Property file is a typical plain java file with key and value pairs. It will have an extension of .properties.  Usually system level configurations or server level configuration. Each line typically refers to a configurable parameter. Format looks like key=value . Key being the Property name and value being the key’s Value. This is the simple Properties file  used in our sample program....

How to Create XML Document or String Object in Java Dynamically

Explanation: This sample example will construct a XML / DOM / Document Object in java. We will create new instance of DocumentBuilderFactory using DocumentBuilderFactory.newInstance() method. The newDocumentBuilder will create new instance of DocumentBuilder with configured parameters. The newDocument() method will create new instance of Document Object to Build a DOM Tree.Element is an...

How to Convert a Document DOM Object to XML String Object

Explanation: Document is an interface in org.w3c.dom package which extends Node Interface. This example is all about converting a document object to String Object which will be a valid XML. The method getXMLFromDOM() will take Document object as argument. So, we have created a document object using the method createDocument(). This createDocument() method is inturn clearly explained in my post...

How to Convert a XML String to Document Object

Explanation: Document is an interface in org.w3c.dom package. It extents Node interface.  The domFactory.setNameSpaceAware()  method will have argument “true” as our parser produced will support XML namespace. In this example, we will give getDocFromXMLString() Method a String Argument. Please Note that this String Argument must be a  valid XML. The newDocumentBuilder will create new...