Tuesday, October 08, 2013

RSA Public Key Encryption and Private Key Decryption using Java

In Previous Post, I have discussed about What is Cryptography, What are Types of it and How we can encrypt and decrypt data using DES Algorithm in Java

Asymmetric Cryptography :
  • Here, We share Public Key with others so they can encrypt data using Public Key
  • We can only decrypt data using Private Key associated with Public Key. Private key is secret one and we don't share with anyone.
  • Most common used algorithm is RSA ALGORITHM. named after Rivest,Shamir and Adleman

Friday, October 04, 2013

Calibration Data Missing in Netbeans 7.3

While I was doing profiling using netbeans 7.3,I encountered with Issue "Calibration Data Missing" when we are using profiling first time and after reading netbeans documentation found solutions which is mentioned as below.

To Solve, "Calibration Data Missing" Issue,

Tuesday, September 24, 2013

TreeMap Example in Java

TreeMap maintains ascending order and does not allows null as Key which differs in HashMap and LinkedHashMap.

About TreeMap:
  • It extends AbstractMap class and Implements NavigableMap Interface
  • It maintain ascending order
  • It does not allow null as Key

LinkedHashMap Example in Java

LinkedHashMap is used for Key-Value concepts. when we require to store values based on Key then LinkedHashMap is for You !But It maintains insertion order while HashMap does not.

About LinkedHashMap:
  • It extends HashMap class and Implements Map Interface
  • It maintain insertion order
  • Allows null as Key and Values also

HashMap Example in Java

HashMap is used for Key-Value concepts. when  we require to store values based on Key then HashMap is for You !

About HashMap :
  • HashMap is class which extends AbstractMap and Implements Map Interface
  • HashMap does not maintain insertion order

TreeSet Example in Java

About TreeSet:
  • TreeSet is class which extends AbstractSet and Implements NavigableSet Interface
  • It does maintain ascending order
  • It does not allow null
  • Contains unique elements Only, same as HashSet and LinkedHashSet

LinkedHashSet Example in Java

About LinkedHashSet :
  • LinkedHashSet is class which extends HashSet and Implements Set Interface
  • It maintain insertion order
  • Allows null
  • Contains unique elements Only

HashSet Example in Java

About HashSet:
  • HashSet is class which extends AbstractSet and Implements Set Interface
  • It does not maintain insertion order
  • It allow null
  • Contains unique elements Only, same as LinkedHashSet

Wednesday, September 18, 2013

Thread Pooling using Executors and ThreadPoolExecutor in Java

Thread Pool manages pool of threads waiting for job. They are called worker Threads.Initially threads are waiting in pool for job and once they will get job to process, it will be process that job and move back to thread pool and wait for another job.

As mentioned in below example, I have create fixed size of Thread Pool with 5 worker threads. Now I will submit 10 jobs which should be processed by worker threads in Thread Pool. But Since I have only 5 Threads available in Thread pool, how it will work?

Thread Interrupt Example in Java

Thread class provides method interrupt() using which one can Interrupt thread.

Before moving ahead, It's important to understand following scenarios :
  • If Thread is blocked in invocation of method like sleep(),join() or Object.wait then It's interrupted status will be cleared and InterruptedException will be thrown.
  • If Thread is blocked in IO Operation upon java.nio.channels.InterruptibleChannel then channel will be closed and interrupted status will be set. Here, Thread will receive ClosedByInterruptException