Wednesday, June 26, 2013

hadoop


Open the Two files and paste the below two lines.
deb http://ppa.launchpad.net/webupd8team/java/ubuntu quantal main
deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu quantal main

Now Follow from the Step 7

The Below link for setup a Apache Hadoop in Multi Node Cluster (Apache Hadoop Version is 1.0.4)
http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-multi-node-cluster/

Finally, i didnt tried HBase so you get it from the hbase.apache.org or cloudera sites.

Thursday, June 20, 2013

String Function in Java


Java: Trim an string

Find a way to trim the last character of a StringBuilder or a String for that matter.

If you have a String called 's'
Code:
s.substring(0, s.length()-1);
If you have a StringBuilder 'sb'
Code:
sb.deleteCharAt(sb.length()-1);

Java: Sort an array

Description

The java.util.Arrays.sort(int[]) method sorts the specified array of ints into ascending numerical order.

Declaration

Following is the declaration for java.util.Arrays.sort() method
public static void sort(int[] a)

Parameters

  • a -- This is the array to be sorted.

Return Value

This method does not return any value.

Example:

int[] array = new int[10];
Random rand = new Random();
for (int i = 0; i < array.length; i++)
    array[i] = rand.nextInt(100) + 1;
Arrays.sort(array);
System.out.println(Arrays.toString(array));
// in reverse order
for (int i = array.length - 1; i >= 0; i--)
    System.out.print(array[i] + " ");
System.out.println();

Java: substring an String

Description:

This method has two variants and returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string or upto endIndex - 1 if second argument is given.

Syntax:

Here is the syntax of this method:
public String substring(int beginIndex)

or

public String substring(int beginIndex, int endIndex)

Parameters:

Here is the detail of parameters:
  • beginIndex -- the begin index, inclusive.
  • endIndex -- the end index, exclusive.

Return Value :

  • The specified substring.

Example:

import java.io.*;

public class Test{
   public static void main(String args[]){
      String Str = new String("Welcome to Tutorialspoint.com");

      System.out.print("Return Value :" );
      System.out.println(Str.substring(10) );

      System.out.print("Return Value :" );
      System.out.println(Str.substring(10, 15) );
   }
}
This produces following result:
Return Value : Tutorialspoint.com
Return Value : Tuto