Encode a JSON array in JAVA
Encode a JSON array import org.json.simple.JSONArray; JSONArray list = new JSONArray(); list.add("foo"); list.add(new Integer(100)); list.add(new Double(1000.21)); list.add(new...
View ArticleMerge two JSON objects in JAVA
//import org.json.simple.JSONObject; JSONObject obj1 = new JSONObject(); obj1.put("name","foo"); obj1.put("num",new Integer(100)); obj1.put("balance",new Double(1000.21));...
View ArticleMerge two JSON arrays in JAVA
JSONArray list1 = new JSONArray(); list1.add("foo"); list1.add(new Integer(100)); list1.add(new Double(1000.21)); JSONArray list2 = new JSONArray(); list2.add(new Boolean(true));...
View ArticleCreate JSON using Combination of JSON primitives, JSON object and JSON arrays
JSONArray list1 = new JSONArray(); list1.add("foo"); list1.add(new Integer(100)); list1.add(new Double(1000.21)); JSONArray list2 = new JSONArray(); list2.add(new Boolean(true));...
View ArticleCreate WAR file using Ant
All the classes inside the src directory should be compiled and placed in a separate build/classes directory. The created war file will be placed inside the dist directory. So first we create the...
View ArticleFactory pattern – Design Patterns in Java/J2EE
Creational pattern deals with the creation of objects and it hides the complex logic involved in the object creation object from the clients. One of the common creational patterns is the Factory...
View ArticleCustomize JSON outputs – Streaming
class User implements JSONStreamAware{ private int id; private String name; private String password; public User(int id, String name, String password){...
View ArticleCross domain call using JSON AJAX in java
in jsp page write your scipt <script type=”text/javascript”> $(function(){ var url=”www.anyotherurl.com”; $.getJSON(url+”&jsoncallback=?”, function(data) { alert(data.key); }); })...
View Articlecall another server using JAVA
URL url = new URL(“www.anotherurlwithparameter.com”); System.out.println(“url==”+url); HttpURLConnection connection = null; connection = (HttpURLConnection) url.openConnection();...
View ArticleInstalling Hadoop on Ubuntu (Linux)
1. Installing Sun JDK 1.6: Installing JDK is a required step to install Hadoop. 2. Adding a dedicated Hadoop system user: You will need a user for hadoop system you will install. To create a new user...
View ArticleInstall Apache HBase
To Download hbase go to : http://www.apache.org/dyn/closer.cgi/hbase/ Download it. and place it anywhere(e.g. hbase/hbase/bin) Go to root [administrator@CentOS63 ~]$ su Password: [root@CentOS63...
View ArticleJava Example Code using HBase Data Model Operations
import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HColumnDescriptor; import...
View ArticleHBase MapReduce Summary to HBase Example
The following example uses HBase as a MapReduce source and sink with a summarization step. This example will count the number of distinct instances of a value in a table and write those summarized...
View ArticleHbase Map Reduce Program (read content from the table and write the same...
First of all create a table test and insert data. and create a second table target. Below program read all the content from test table and copy into target table. import java.io.IOException; import...
View ArticleWhat is Java String Pool?
As the name suggests, String Pool is a pool of Strings stored in Java heap memory. We know that String is special class in java and we can create String object using new operator as well as providing...
View ArticleWhy String is immutable or final in Java?
String is one of the most used classes in any programming language. As we know that String is immutable and final in java and java runtime maintains a String pool that makes it a special class. String...
View ArticleHow to write an immutable Class?
Immutable objects are instances whose state doesn’t change after it has been initialized. For example, String is an immutable class and once instantiated its value never changes. Immutable objects are...
View ArticleString intern
When we use new keyword to create the String object in heap, it doesn’t go into the String Pool. When we call intern method, then it checks if any String with same value is already present in the pool...
View ArticleInterpreter Vs Compiler :
We generally write a computer program using a high-level language. A high-level language is one which is understandable by us humans. It contains words and phrases from the English (or other) language....
View ArticleGeneralization and Specialization
Generalization is a mechanism for combining similar classes of objects into a single, more general class. Generalization is a bottom-up process. Generalization and inheritance are powerful abstractions...
View Article
More Pages to Explore .....