Friday, July 8, 2011

Rename multiple files

rename 's/\.htm$/.html/' *.htm

# or

find . -name '*.txt' -print0 | xargs -0 rename 's/.txt$/.xml/'

#Obs1: Above I use regex \. --> literal '.' and $ --> end of line
#Obs2: Use find -maxdepht 'value' for determine how recursive is
#Obs3: Use -print0 to avoid 'names spaces crash!

Friday, July 1, 2011

Collection in Java

Collection is a framework for keeping a group of objects. It is not synchronized. They are basically of two types: list and set. Some of them are ordered while some allow duplicates. List can contain duplicate elements while set cannot

Features of List
  1. Ordered
  2. Eg: Arraylist, linkedlist

ArrayList
  1. positional access : Constant time
  2. Addition and deletion: Linear time
LinkedList
  1. positional access : Linear time
  2. Addition and deletion: Constant time

Features of Set
  1. Eg. HashSet, TreeSet

HashSet
  1. Faster but offers no ordering guarantee
  2. Since the iteration is linear in sum of number of entries and capacity, choosing the size of hashset makes the code faster

If we need to use the operations in SortedSet or if in-order iteration is important to you, use TreeSet.

Since their is no synchronization in Collection, it is generally faster than Hashtable and Vector.

More information is available at following link

Prologue

I have started this blog to maintain accountability of each day. I think this blog will motivate me to do something new everyday and avoid feeling the guilt of wasting the day !!