Wednesday, January 19, 2011

Best Tutorial for SVN Installation on Windows

http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html

This is the best Tutorial I found on the Net For Installing SVN on Windows.
The following Link help you to Download SVN svn-1.4.6-setup.

Once you have Installed in Program files it provides the Tutorials, Which resolves most of u r concerns.

How to Configure SVN Server as a Windows Service: Best Article

    Configuring svnserve to Run as a Windows Service


http://svn.spears.at/ : The complete Tutorials.

Thursday, January 6, 2011

Conversion between Array and java.util.List

While dealing with Autogenerated Classes Like JAXB or any other framework we need to convert from Array to List or vice versa..

Object[] --> java.util.List
or
java.util.List --> Object[].

Array to List
    public static void main(String[] args) {
           String[] names= {"Name 1","Name 3","Name 4"};
           List nameList=Arrays.asList(names);
           System.out.println("List Size is :"+nameList.size());
           System.out.println("Names are :"+nameList);
    }
It will give the Output as
   List Size is :3
   Names are :[Name 1, Name 3, Name 4]

We know how to insert the data in some position in List, But the insertion will not be allowed in the List provided by Arrays.asList,

It throws the following Exception when we do
   nameList.add(2,"Name 2");
   or 
   nameList.add("Name 2");

   Exception in thread "main" java.lang.UnsupportedOperationException
           at java.util.AbstractList.add(AbstractList.java:151)
           at java.util.AbstractList.add(AbstractList.java:89)
           at org.work.corejava.collection.ArrayToList.main(ArrayToList.java:12)
Reason: Reference
Arrays.asList Returns a fixed-size list backed by the specified array. (Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray.

But as the array supported
    names[1] ="Name 2";
    The same functionality will be supported by List also , as follows.
    nameList.set(1,"Name 2");
List to Array

List to Array can be done using the following Code.
String[] namesArray = nameList.toArray(new String[0]);
      in JDK 1.4 we need to do teh following type casting.
      String[] namesArray = (String[])nameList.toArray(new String[0]);

Monday, January 3, 2011

How you can stop Rumors, a Simple way is here....

Here is something which I thought is an Excellent Stuff to share...



QUOTE

In India around 350 BC in Magadh, Chanakya was widely lauded for his wisdom.

One day an acquaintance ran up to him excitedly and said, "Chanakya ji, do you know what I just heard about Pandit Haridas?"

"Wait a moment," Chanakya replied, "Before you tell me I'd like you to pass a little test. It's called the Triple Filter Test."

'Triple filter?" asked the acquaintance.

"That's right," Chanakya continued, "Before you talk to me about Pandit Haridas, let's take a moment to filter what you're going to say. The first filter is Truth. Have you made absolutely sure that what you are about to tell me is true?"

"No," the man said, "Actually I just heard about it."

"All right," said Chanakya, "So you don't really know if it's true or not. Now let's try the second filter, the filter of Goodness. Is what you are about to tell me about Pandit Haridas something good?"

"No, on the contrary..."

"So," Chanakya continued, "You want to tell me something about Pandit Haridas that may be bad, even though you're not certain it's true?"

The man shrugged, a little embarrassed. Chanakya continued, "You may still pass the test though, because there is a third filter, the filter of Usefulness. Is what you want to tell me about Pandit Haridas going to be useful to me?"

"No, not really."

"Well," concluded Chanakya, "If what you want to tell me is neither True nor Good nor even useful, why tell it to me or anyone at all?"

The man was bewildered and ashamed. This is an example of why Chanakya was a great politician and held in such high esteem.