tag:blogger.com,1999:blog-85233873370637444122024-03-13T05:38:35.321+05:30Java WorldJava tips and tricks for developersAnonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-8523387337063744412.post-8662747218891934952010-08-04T01:52:00.000+05:302010-08-04T01:54:31.926+05:30ArrayList vs VectorsMany people coming from Java 1.4 era seem to have a liking for Vectors. Before the Collections framework brought with it loads of classes, Vectors were a good option to fall back on when you wanted a growable array of objects. Vectors did the job well, but then, there are differences how Vectors and ArrayLists work. So, don't just jump and adopt Vectors if what you need is just an ArrayList. I am listing down a comparison between the two.<br />
<br />
<ul><li>Vectors are synchronized while ArrayLists are not. So, if you need to work within a multi-threaded environment, then choose Vectors. But, if you don't even know what multi-threading is, or you do not want the access to be synchronized, use ArrayList. ArrayLists will give you a performance improvement over Vectors in a non-multi-threaded environment.</li>
<li>When Vectors grow, they do so by a factor of 2, while ArrayList grow by a factor of 1.5. In most of the cases, this fact doesn't matter. But, if you are writing alogrithms and performance intensive code, you should consider this difference.</li>
<li>The growth factor can be adjusted for a Vector, if you really need to change that. But for ArrayLists, this cannot be changed.</li>
<li>Both ArrayLists and Vectors have excellent performance when it comes to retrieving elements by index. Updating through indexes are also fast. </li>
</ul>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-85214075578808267432009-05-26T02:14:00.001+05:302009-05-26T02:14:02.609+05:30Java Program: Fibonacci Example<p>The first two <a href="http://en.wikipedia.org/wiki/Fibonacci">Fibonacci</a> numbers are 0 and 1, and each remaining number is the sum of the previous two.</p> <p>Here is the source code for generating the Fibonacci Series by using Recursion. </p> <p>public class Fibonacci { <br />    //Number of Fibonacci numbers to be shown <br />    static int limit= 10; <br />    static int count = 0; <br />    public static void main(String[] args) {        <br />        System.out.print(0+” “); <br />        fibo(0,1); <br />    } <br />    //Recursive Function <br />    private static void fibo(int i, int j) { <br />        count++; <br />        System.out.print(j+" "); <br />        if(count==limit) <br />            return; <br />        fibo(j,i+j); <br />    } <br />}</p> <p>This piece of code is ready to run. Copy this code into a file called Fibonacci.java, compile it and run. Here is the sample output of the above program. To generate the required number of numbers in the sequence, adjust the value of the integer variable “limit”.</p> <p>0 1 1 2 3 5 8 13 21 34 55 </p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com1tag:blogger.com,1999:blog-8523387337063744412.post-86897384963543890102009-05-16T01:27:00.001+05:302009-05-16T01:27:03.841+05:30Java Design Patterns I<p>Here is a list of the most widely used design patterns in Java. I will write down about the details in my subsequent posts.</p> <p>1. Creational  Patterns</p> <ul> <li>Abstract Factory</li> <li>Builder</li> <li>Factory Method</li> <li>Prototype</li> <li>Singleton</li> </ul> <p>2. Structural Patterns</p> <ul> <li>Adapter</li> <li>Bridge</li> <li>Composite</li> <li>Decorator</li> <li>Facade</li> <li>Flyweight</li> <li>Proxy</li> </ul> <p>3. Behavioural Patterns</p> <ul> <li>Chain of Responsibility</li> <li>Command</li> <li>Interpreter</li> <li>Iterator</li> <li>Mediator</li> <li>Memento</li> <li>Observer</li> <li>State</li> <li>Strategy</li> <li>Template Method</li> <li>Visitor</li> </ul> <p>4. J2EE Patterns</p> <ul> <li>MVC</li> <li>Business Delegate</li> <li>Composite Entity</li> <li>Data Access Object</li> <li>Front Controller</li> <li>Intercepting Filter</li> <li>Service Locator</li> <li>Transfer Object</li> </ul> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com2tag:blogger.com,1999:blog-8523387337063744412.post-47875595163796263792009-05-11T15:42:00.001+05:302009-05-11T15:42:21.687+05:30Java Interview Questions: Collections III<p>I am writing down some more questions that could come up during an interview. A large number of questions are asked from the Collections API. But, of-course, questions from collections would sometimes require you to be comfortable with other basic Java fundamentals, like over-ridding, over-loading, hashCode(), equals() etc. </p> <p><strong>Q1. What are hashcodes used for?</strong></p> <p><strong>Ans. </strong>Hash Codes are used for increasing the performance of large collections. The Hash Code value of an object is used by some collection classes. One might think that hash codes are unique, but there can be situations, where the hash codes of different objects become the same. But you really don’t have to bother about this, since the collection classes those use hash codes, provide for a fail-over implementations for such cases.</p> <p><strong>Q2. What should we keep in mind while over-riding equals() and hashCode()?</strong></p> <p><strong>Ans. </strong>You should over-ride these methods in such a way that when two objects are equal, the hash codes generated for both of them must be equal.</p> <p><strong>Q2. Is it required that if two objects are not equal, their hash codes will always be different?</strong></p> <p><strong>Ans. </strong>Not necessarily. Think of a situation like this. When you are generating a hash code for a string based on the characters.</p> <p>ABC‘s hash code = 6 (Add the numeric values of the alphabets)</p> <p>BAC in such a situation would also have the same hash code. Though, both the strings are different, their hash codes are the same. This design is ok, since both of them will be put into the same bucket, and still you would be able to find them. But, ensuring that, the hash codes of two different objects are never same, will only improve the performance of hash-tables.</p> <p><strong>Q3. What is a Marker Interface?</strong></p> <p><strong>Ans. </strong>A marker interface is one which doesn’t have any method definitions. For example, Cloneable or Serializable. They are just empty interface definitions. Now, the question is what is the use of such an interface? Here we go. There is a method in the Object class, clone(), which is used to clone objects. So, we should be able to clone any kind of object anywhere. To prevent this, we have Marker Interfaces. Only if we declare that class as implementing the Cloneable, we can clone the objects of that class, else we will get an exception. Thus, implementing Cloneable class, which is a marker interface, just tags that class as “Hey, You can clone me know”. And the clone() method will not throw any exception. Same is the case with Serializable. If the class is not implementing the Serializable interface, any attempt to write the Object/ or serialize it will fail.</p> <p><strong>Q4. What are the different Marker Interfaces?</strong></p> <p><strong>Ans. </strong>Cloneable, Serializable, EventListener,</p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com3tag:blogger.com,1999:blog-8523387337063744412.post-73684229376520216682009-05-10T02:47:00.001+05:302009-05-10T02:47:54.768+05:30Java Interview Questions: Basics II<p>Here are another set of questions asked in interviews that test one’s foundation knowledge or concepts in Java. We read these once and tend to forget. We can only remember these tips when you regularly start using these in your programming. Let’s begin.</p> <p><strong>Q1. Which of these is thread-safe? “StringBuilder” or “StringBuffer”?</strong></p> <p><strong>Ans. </strong>StringBuffer is synchronised, thus making it slower than the StringBuilder.</p> <p><strong>Q2. Why a String is immutable in Java?</strong></p> <p><strong>Ans. </strong>By design, Java maintains the strings in a particular way. It has a String constant pool where all the string literals are stored. When a new string is created, it first checks if the literal is already present in the pool. If it finds one, it just returns the reference to the variable instead of creating a new literal in the memory. Thus, a single string literal in the memory can have multiple references. So, if strings weren’t immutable, changing this string literal will also affect the other references which of-course is dangerous and undesired. This is why Strings are immutable. For this reason, the String class is also marked as <strong>final</strong> so that it’s functionality cannot be over-ridden, and thus the Strings remain as immutable for everyone.</p> <p><strong>Q3. What is the difference between these two statements?</strong></p> <p><strong>String s1 = “abc”;    and String s2 = new String(“def”);</strong></p> <p><strong>Ans. </strong>In the first case, “abc” will go into the string constant pool and s1 will refer to it. While in the second statement, since we have mentioned the new keyword, a new string object will be created in the normal(non-pool) memory, and s2 will refer to it. Additionally, the literal “def” will be placed in the pool.</p> <p><strong>Q4. Why should we prefer not to use Strings when we need to modify it’s value again and again?</strong></p> <p><strong>Ans. </strong>As we just discussed, every string created in the Java, puts the literal in the memory pool. So, even if a literal has no more references to it, it will still be in the memory in an abandoned state. Thus, when constant modification operations are required to be made, at the end, we might have a large number of abandoned string literals in the memory which are of no use. In such cases, we should use StringBuffer or Stringbuilder, which can be modified over and over again without filling up the memory with abandoned literals.</p> <p><strong>Q5. What is the importance of close() and flush() in file or stream I/O ?</strong></p> <p><strong>Ans. </strong>When we are done with reading or writing, we should always close the Reader or Writer objects, so that the resources could be freed up for others to use. To do this, we should call close() method on those objects.</p> <p>While writing to a file/stream, some amount of buffering is always carried out, instead of putting the data character by character or byte by byte. So, if you don’t flush the stream, before closing the Writer object, whatever data is in the buffer, will never be written onto the file/stream. So, it is always a good practice to use flush() just before close(). </p> <p><strong>Q6. What are the three principles of OOP?</strong></p> <p><strong>Ans. Encapsulation, Polymorphism and Inheritance.</strong> You would say that everyone knows this. But I was surprised when someone asked me this question. I wasn’t able to remember the word “Encapsulation”. That was really strange!!!!!   :)</p> <p><strong>Q7. What type of parameter passing does Java support?</strong></p> <p><strong>Ans. </strong>Java supports only “Passing by values”.</p> <p><strong>Q8. Can I write multiple main methods in a class?</strong></p> <p><strong>Ans. </strong>Yes, you can do that, but there should be one which should be declared “public static void main(String[] args){}”.</p> <p><strong>Q9. Can constructors be overridden in a sub-class?</strong></p> <p><strong>Ans. </strong>Constructors are not inherited by a sub-class when it extends another class. Thus, there is no question of overriding a constructor.</p> <p><strong>Q10. Can a constructor have a return type?</strong></p> <p><strong>Ans. </strong>No, if you specify a constructor with a return type, be it void, it won’t be treated as a constructor any more. It will be treated as a normal method of that class, even if the name of the method matches with the class name.</p> <p>More questions would follow. If you have doubts, please comment and I will try to answer your queries as soon as possible.</p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com2tag:blogger.com,1999:blog-8523387337063744412.post-78970284768614483652009-05-09T19:10:00.001+05:302009-05-09T19:10:43.694+05:30Java Interview Questions: Threads I<p><strong>Q1. Can we call the run() method instead of start() ?</strong></p> <p><strong>Ans. </strong>Yes, we can do that. But, this will not start a new thread. The contents of the run method will be executed just as a method call, in the existing thread. If you want to start a new thread, you should call the start() method only. The start() method will, in turn call the run() after creating a new thread of execution.</p> <p><strong>Q2. Why is the sleep method static ?</strong></p> <p><strong>Ans. </strong>There are many static methods in the Thread class. They all operate on the current thread, that is, the thread that executes the method. You cannot perform these operations on other threads.</p> <p><strong>Q3. What are daemon threads?</strong></p> <p><strong>Ans. </strong>Daemon threads are nothing but a very low priority threads. They have no particular role, other than helping the other threads. When only daemon threads remain, then the program exits.</p> <p><strong>Q4. What is the default priority of a newly created thread?</strong></p> <p><strong>Ans. </strong>NORM_PRIORITY or 5.</p> <p><strong>Q5. What are the two ways of creating a new thread?</strong></p> <p><strong>Ans. </strong>1. Extending the Thread class    2. Implementing the runnable interface</p> <p><strong>Q6. What are the four states associated with a thread?</strong></p> <p><strong>Ans. </strong>new   runnable    blocked    dead</p> <p><strong>Q7. What happens if we call start() on a thread object which is already started?</strong></p> <p><strong>Ans. </strong>Nothing will happen. A thread can only be started once. After that, even if in a dead state, a thread cannot be re-started. Calling the start method again will cause an exception (IllegalThreadStateException), a kind of RuntimeException.</p> <p><strong>Q8. What does yield() method do?</strong></p> <p><strong>Ans. </strong>This method makes the current running thread move to runnable, to allow other threads of the same priority get their chance. A yield() call will never send a running thread to waiting/sleep/blocking state. At the most, the current thread will go to runnable thread. But again, if there are no other threads to run, this thread might again be picked up by the scheduler, thus having no superficial effect at all. That is, it is as good as, that the call was never made.</p> <p><strong>Q9. What does join() call do?</strong></p> <p><strong>Ans. </strong>When it is required that a thread, say A, cannot proceed before the completion of another thread say, B, then we ask the thread A to join B. By doing so, we are telling A, to proceed only when the thread B has finished it’s job.</p> <p><strong>Q10. Why should we avoid unnecessary Synchronisation?</strong></p> <p><strong>Ans. </strong>Synchronisation prevents concurrent execution. Thus, when a thread is inside a synchronised method, other threads cannot enter that method. While,the main objective of multi-threading is to allow concurrency, synchronisation prevents it. So, only when absolutely necessary, we should use synchronisation.</p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-381788942465885882009-05-04T18:42:00.001+05:302009-05-04T18:42:10.375+05:30Java Interview Questions: Collections II<p>Here are some more interview questions on Collections. Recently, I had an interview in which these were asked. Well, I couldn't answer all of them. Check how many you know.</p> <p><strong>1. What is the difference between Comparator and Comparable?</strong></p> <p><strong>Ans.</strong> Both interfaces are used to sort a list or a collection of objects. However, to implement a Comparable, a class must implement a single method compareTo(anotherObj). By doing this, you can sort a class accordingly whatever you have implemented in this method, i.e, perhaps only on a single criteria. Only one sort sequence can be created and you have to modify the class whose instances you want to sort. Through Comparable, you can compare the instances of the same class, since the logic is written inside the class itself. “The comparable interface <strong>should</strong> be used when the current object is to be compared to objects of its type only.”</p> <p>The Comparator interface gives you the extra feature of sorting your collection in any number of ways. Here also, we have to implement only one method, i.e, compare(objOne,objTwo). Here, many sort sequences can be created. Instead of making changes to the class, you define a separate class from the class whose instances you want to sort. Thus, a Comparator can compare two objects(any objects for that matter) and return the result based on the criteria imposed by the Comparator. “The comparator should be used when some external class is taking your class as a parameter for some comparison operation and it doesn't know how to compare the objects and expects you to give it.”</p> <p><strong>2. Does a HashMap allow null as a key and value?</strong></p> <p><strong>Ans. </strong>Yes, you can put a null as a key, and values as null as well. Whereas, Hashtable doesn’t allow anything as null, neither a key or a value. The point of allowing a null as key is not clear though.</p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com5tag:blogger.com,1999:blog-8523387337063744412.post-34339876276112673052009-05-04T00:02:00.001+05:302009-05-04T00:02:52.557+05:30Java Interview Questions : Collections I<p> </p> <p><strong>1. What is the difference between the size and capacity of a Vector?</strong></p> <p><strong>Ans. </strong>Vector is a grow-able collection of objects. The size tells us the number of elements actually stored in the vector, while it’s capacity tells us the maximum number of elements that it can store at a given instance of time. Capacity is increased automatically when the Vector is filled up with elements to a threshold level which is determined by it’s load factor.</p> <p><strong>2. What is the difference between an Iterator and a ListIterator?</strong></p> <p><strong>Ans. </strong>Iterator is an interface which allows you to iterate all the elements in a collection, but only in the forward direction. While, ListIterator extends the Iterator, it has the added functionality of b-directional traversal of the collection.</p> <p><strong>3. How is a Set different from a List?</strong></p> <p><strong>Ans. </strong>Set is a data structure in which no duplicates are allowed, and also it doesn’t preserve the order of the elements. List, on the other hand, allows duplicate elements to be present, and also maintains the order of the elements.</p> <p><strong>4. What is the difference between Enumeration and Iterator?</strong></p> <p><strong>Ans. </strong>Both have the same functionality, i.e, traverse through all the elements in a collection. But they are different in only one respect, Enumeration allows you to only traverse and fetch elements from a collection, without any provision of manipulating the collection, i.e, addition, deletion, updation. Using an iterator, you can even manipulate the collection, in addition to traversal and fetching.</p> <p><strong>5. What are the differences between an ArrayList and a Vector?</strong></p> <p><strong>Ans. </strong>Though the implementations for the both are the same, the Vector is synchronized while an ArrayList isn’t.</p> <p><strong>6. How will you remove duplicate elements in a List?</strong></p> <p><strong>Ans. </strong>As we already know, a Set cannot contain duplicate elements, you just add the List elements to a Set. the duplicates will not be added.</p> <p><strong>7. Which data structure is to be used when fast iteration and random access is required?</strong></p> <p><strong>Ans. </strong>ArrayList</p> <p><strong>8. When should we use LinkedList?</strong></p> <p><strong>Ans.</strong> In LinkedList, new elements are added to the ends, ex, Queues and Stacks. However, you can still add or delete elements in a LinkedList in the middle, but this process eats up a lot of resources in breaking and making the links between two elements. So, when we don’t need any insertion or deletion in between, but only at the ends, we should use LinkedList.</p> <p><strong>9. What is the use of a hashCode() in Java?</strong></p> <p><strong>Ans. </strong>They are used in certain collection classes where the elements are stored as key/value pairs, such as HashMap, Hashtable, where hashCodes are used for their storage and retrieval.</p> <p><strong>10. When you want to search an element by it’s index, which of these would you use?</strong></p> <p><strong>Ans. </strong>ArrayList, of course.</p> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-2959283930878621502009-05-03T03:09:00.001+05:302009-05-03T03:09:35.352+05:30Java Interview Questions : Basics I<blockquote> <p>Here are some questions that are normally asked in interviews for Java candidates.</p> <p><strong>1. Which is the default package that is imported even if you don’t specify it explicitly?</strong></p> <p><strong>Ans. </strong>java.lang</p> <p><strong>2. When you specify import java.package.*, does it import all the sub-packages inside it?</strong></p> <p><strong>Ans. </strong>No, for importing them, you will need to add more import statements such as, import java.package.sub.* etc.</p> <p><strong>3. What is the concept of a package in Java, why do we need packages?</strong></p> <p><strong>Ans. </strong>This is a feature by which you can manage your classes, and prevent class name collisions. Think of a situation when your application has 1000s of classes. Say, for a bank application, there can be a Credit Card account and a Debit Card Account. You need to have a class for Account. But, you cannot have two different classes with the same name. Putting the two accounts classes in different packages will allow you to have two classes with the same name which exist in different packages.</p> <p><strong>4. Is it an error to add a package more than once?</strong></p> <p><strong>Ans. </strong>No, neither the compiler or the JVM will report any error. While executing, it will be imported only once, no matter how many times you import a package.</p> <p><strong>5. What is the difference between the following operations, equals() and == ?</strong></p> <p><strong>Ans. </strong>== will only compare the references, i.e, if they are present in the same memory location, while equals() will compare the contents of the references. But the output of the equals() operator might not be as expected if the equals() method is overwritten in any class. It is imperative that whenever you overwrite the equals() method , you should also override the hashCode() method, if you want your classes to be used by some collection classes.</p> <p><strong>6. Which is the root class of all Java classes?</strong></p> <p><strong>Ans. </strong>It is the java.lang.Object class.</p> <p><strong>7. Will there be a problem if the main method is not declared as static?</strong></p> <p><strong>Ans. </strong>You will not get a compile time error, but at run time, it throws an error, “Main method not public”, since the JVM will look for a static main method to execute a program. The main method is the only entry point to a Java program.</p> <p><strong>8. I have an object of some type, how do I figure out it’s class?</strong></p> <p><strong>Ans. </strong>If you want to get its class name, then  </p> <p>object.getClass() will return the fully qualified Class name of that object. If you want to check if that object is a type of a specific class, you can use instanceOf keyword which will return a boolean value depending upon the match.</p> <p><strong>9. Can a constructor of a class be private?</strong></p> <p><strong>Ans. </strong>Yes, but then, you cannot create an instance of such a class directly. This is done in building Singleton classes. Please refer to Singleton design pattern to know more.</p> <p><strong>10. Can a constructor return a value?</strong></p> <p><strong>Ans.</strong> No, this will give a compiler error. You cannot even return a void.</p> <p><strong>11. Can a constructor be static?</strong></p> <p><strong>Ans. </strong>No.</p> <p><strong>12. Are constructors inherited, i.e, can they be overwritten in a sub class?</strong></p> <p><strong>Ans. </strong>No.</p> <p><strong>13. Can a constructor be declared as “native”?</strong></p> <p><strong>Ans.</strong> No.</p> <p><strong>14. Can a constructor be synchronized?</strong></p> <p><strong>Ans. </strong>No.</p> <p><strong>15. In Java, do we have Pass by Value or Pass by Reference?</strong></p> <p><strong>Ans.</strong> Java doesn’t support pass by reference. Everything in Java is Pass by Value.</p> <p><strong>16. How can we restrict a class from being instantiated directly?</strong></p> <p><strong>Ans.</strong> This can be done by either marking it as “Abstract” or making it’s constructor “private”.</p> <p><strong>17. What is the difference between J2SDK 1.5 and J2SDK 5?</strong></p> <p><strong>Ans.</strong> No difference, they are the same, but SUN came up with a fancy name. It is widely referred to as “<strong>Java 5”</strong>.</p> <p><strong>18. A method doesn’t have an access specifier. Is this OK?</strong></p> <p><strong>Ans. </strong>Yes, this method will now have default access, meaning within that package in which the class is defined.</p></blockquote> Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com2tag:blogger.com,1999:blog-8523387337063744412.post-74470476587578238502008-11-04T00:31:00.000+05:302008-11-04T00:36:16.116+05:30Laptop Keyboard Keys Fell Off !!!!Here is a very good article on how to put back the keys that fell off your laptop. I was trying to clean my laptop when I accidentally uprooted one of its keys. After banging my head on how to put it back for almost about an hour, I found a link explaining how to do it. And, my key was back to its place in 5 minutes. Thanks....<br /><br />Check out this link:<br /><br /><a href="http://www.laptoprepair101.com/laptop/2007/03/20/key-fell-off-keyboard/" title="Repair Laptop Keyboard">"Fix Laptop Keyboards"</a>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-83974063758371847022008-11-03T21:55:00.000+05:302008-11-03T22:02:37.547+05:30Multiple GTalk Logins<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCiNPOp_kb68I6UQWWJFfyCO94ETpCDSWQaDg1PmT1Jlw7fK4hGLpRdO621DH1K-5HqSgRNrmbDPH5SrqYY1kz4KAs5X9KfWBAeO8k8VszfjreXWBMKiOziygd4EsbD0J09SSZTt0c-zU/s1600-h/Gtalk.png"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer; width: 200px; height: 108px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCiNPOp_kb68I6UQWWJFfyCO94ETpCDSWQaDg1PmT1Jlw7fK4hGLpRdO621DH1K-5HqSgRNrmbDPH5SrqYY1kz4KAs5X9KfWBAeO8k8VszfjreXWBMKiOziygd4EsbD0J09SSZTt0c-zU/s200/Gtalk.png" alt="" id="BLOGGER_PHOTO_ID_5264469903083191746" border="0" /></a><span style="font-weight: bold;font-size:180%;" >I</span> just stumbled upon a site that told me about how to launch multiple GTalk windows and log in as different users with different GTalk windows.<br /><br />Things you need to do:<br />1. Create a shortcut for GTalk on your desktop or Quick Launch bar.<br />2. Right click the icon and then in the Target Field, edit the value to add a new parameter like this.<br /> "C:\Program Files\Google\Google Talk\googletalk.exe" /nomutex<br /> Note: The only thing you need to add here is "/nomutex" after the default Target.<br /><br />Now from this shortcut, you can launch different GTalk clients and log-in with separate user accounts. Happy GTalking.Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-732442444891174902008-06-12T20:54:00.000+05:302008-06-12T23:15:27.400+05:30Google Contacts : The least publicized Google Service<span style="font-family: arial; font-weight: bold;font-size:100%;" > Google Contacts, though you might not think it as a separate Google Service, but if you have a closer look at this application (in my words), you will start appreciating its usefulness. Almost all other Google Services have access to your Contacts, be it GMail, Gtalk, Google Docs, Google Calender, Blogger and so on.<br /><br />And the features that Google Contacts has, makes itself a one of the best Contact/Phone Book Application I have seen. Microsoft Outlook's address book is quite advanced and very user friendly. Google Contacts is in no way less than any of the available Phone-book applications. And the best part is its integration with so many other Google Services.<br /><br />Have a look at the screenshots.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY0hZuB9PBMfkn3lHfBjZEbFfNNXdZac-BYMydVIJ4Jb1IBrP2SXsmIU5pUTlVgCy8qWAvBjkCLp3gIB_KsRuMVWHCDbT83Twg9uERDcsUL6TSxvLVzIAv4_-PKcQuTeT7ZHCFBo_Tgnk/s1600-h/SS6.GIF"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjY0hZuB9PBMfkn3lHfBjZEbFfNNXdZac-BYMydVIJ4Jb1IBrP2SXsmIU5pUTlVgCy8qWAvBjkCLp3gIB_KsRuMVWHCDbT83Twg9uERDcsUL6TSxvLVzIAv4_-PKcQuTeT7ZHCFBo_Tgnk/s320/SS6.GIF" alt="" id="BLOGGER_PHOTO_ID_5211049299060044210" border="0" /></a><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnvLbhkiwmrY9PMcMVHr78fOGSXj5BkFhuWtPDmaPuGNCUNsiu56_s3Hcx-9x9fLW0v1l8waZr_Ovqlmv1NOI8ehS9EL_D4CAJtbiw0FFvACWvnYT03Bq4H86UC-wKfniq_iiHwv6J9Jk/s1600-h/SS5.GIF"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnvLbhkiwmrY9PMcMVHr78fOGSXj5BkFhuWtPDmaPuGNCUNsiu56_s3Hcx-9x9fLW0v1l8waZr_Ovqlmv1NOI8ehS9EL_D4CAJtbiw0FFvACWvnYT03Bq4H86UC-wKfniq_iiHwv6J9Jk/s320/SS5.GIF" alt="" id="BLOGGER_PHOTO_ID_5211049280146479298" border="0" /></a><br /> Can you think of a single field that is missing out. Multiple mail ids, multiple phone numbers, multiple addresses, Title, Company, Notes, IMs, even a photo!!!!....What more do you want? Almost all the fields that are there in an Outlook contact, Google Contacts has them all. Well, I forgot to mention one very small but important thing. There is one more field, which I should probably say as the "Status" which shows the current status of the contact on Gtalk.<br /><br />You can also create groups and then assign each contact to a group. And when you create a group, with some contacts in it, you can see an entry in the pop-up list when you type in something in the "To" field while composing a mail in GMail. Now, in one go, you can send a mail to many people just by mentioning the group name. Isn't this similar with Microsoft Outlook's </span><span style="font-family: arial; font-weight: bold;font-size:100%;" > Distribution Lists?</span><br /><span style="font-family: arial; font-weight: bold;font-size:100%;" ><br />I am sure you must have seen Outlook's brilliant Calender. Please also have a look at Google Calender. With Gmail, Google Contacts and Google Calender combined, isn't it very similar to Microsoft's Outlook. The only difference is that Microsoft provides all these three, packaged in a single application. While Google has separated all these into different applications but within comfortable reach of each other, and for a good reason as well.<br /><br />So much has been spoken already about GMail and to some extent about the Google Calender. But the least popularized or publicized Google Application according to me is the "Google Contacts". Keeping the Contacts as a completely separate application, Google has been able to integrate the same with other services. Now with the launch of Google Android platform, I won't be surprised if they re-use the same Google Contacts and synchronize the phone's phone-book with Google Contacts. Google contacts definitely serves as one of the foundations for all the Google Services. And with the Google Contacts API, you can design your own application to have full control over your contacts.<br /><br />Cheers!!!!!! </span><span style="font-family: arial; font-weight: bold;font-size:100%;" ><br /></span>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-3340159740984016462008-04-10T09:22:00.000+05:302008-04-12T01:17:55.734+05:30STATISTICIAN<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dyPQYJX1Vr8eHkPBQCiCMntjJg8pyeRwHzPwBtJVufayaszV9b5SFvNNVsaJRtM2nksoNDw83Q9iBw74vLmgA' class='b-hbp-video b-uploaded' frameborder='0'></iframe><br /><div style="text-align: left;"><br /></div>My First App with Android<br /><br />Video quality is bad and there is no voice.<br />SORRY FOR THAT<br /><br />You can find a better quality video at YouTube. Here is the link.<br />http://www.youtube.com/watch?v=-EJZHxMCZy0<br /><br />This app shows your call statistics in a graphical format. The normal call log that each phone will have is limited to only few calls. In this app, I record each and every incoming and outgoing call and store them in a file, and then plot the graphs based on this local data.<br /><br />There are currently only 6 views that you can see:<br /><br />1. Total Duration<br />2. Total Incoming (Duration)<br />3. Total Outgoing (Duration)<br />4. Total Calls<br />5. Total Incoming Calls<br />6. Total Outgoing Calls<br /><br />I couldn't implement this for SMSs, since the current SDK doesn't support this feature.<br /><br />There are other improvements that I have thought of, but I started building this app very late.Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com2tag:blogger.com,1999:blog-8523387337063744412.post-4261060761758486562008-02-07T22:25:00.000+05:302008-02-07T23:46:02.165+05:30VLC - Not just a media player<span style="font-weight: bold;font-size:130%;" ><span style="font-family:lucida grande;"> I was so desperately searching for a Video conversation software for such a long time. If you ask me why, to make the long story short, I had some good videos which I wanted to upload to my SE K550i. There are quite a few softwares that might just do the job for free, but I found the quality of their output was much below what I was expecting. And I wasn't willing to pay. What I didn't know was all those hours of searching, cracking the demo softwares would be futile.</span></span><span style="font-size:130%;"><br /><br /></span><span style="font-weight: bold;font-size:130%;" ><span style="font-family:lucida grande;">At last, I gave up, frustrated. And one find day, I installed VLC Player just to be able to play some video formats that were not supported by the well-known players like the ubiquitous Windows Media Player. At first, I was not very impressed by its user-interface. But now its been a year since I am using VLC Player and it has won me over. It's not just a media player, but much more than that.</span></span><span style="font-size:130%;"><br /></span><span style="font-weight: bold;font-size:130%;" ><span style="font-family:lucida grande;"><br />I tried exploring all that it can do to your videos, but its capability of converting videos from one format to another, I would consider the best functionality it has. Lets go through the process of converting a video from MPG format to MPEG-4 (My SE K550i supports MPEG-4).<br /></span></span><span style="font-size:130%;"><br /></span><span style="font-weight: bold;font-size:130%;" ><span style="font-family:lucida grande;">Step 1 - Add the file you want to convert to its play list.</span></span><span style="font-size:130%;"><br /></span><span style="font-weight: bold;font-size:130%;" ><span style="font-family:lucida grande;"><br />Step 2 - Pause the video. The conversion would also work with the video playing, just in case, something goes wrong, pause it.<br /><br />Step 3 - Goto File -> Wizard</span></span><span style="font-size:130%;"><br /><br /></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><span style="font-size:130%;">Step 4 - A wizard will come up. You will have two options here. Choose the second option "Transcode/Save to File. Go to the next screen.</span><br /><br /><br /></span></span><span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4g9j8qee5Vlv3G26Ci5XwTo_TTlRlUH4AudflrPbn-qj97fAjXNMyeaAA8X65cYrZFTY8ZKCmIGhj_B_Q1YOW2Z5WyVyO5ksTuirKQm5DwrNy6lMSy_QddC-Vcx6XrmigH4neY6LaKgA/s1600-h/FirstScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4g9j8qee5Vlv3G26Ci5XwTo_TTlRlUH4AudflrPbn-qj97fAjXNMyeaAA8X65cYrZFTY8ZKCmIGhj_B_Q1YOW2Z5WyVyO5ksTuirKQm5DwrNy6lMSy_QddC-Vcx6XrmigH4neY6LaKgA/s400/FirstScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285075988603698" border="0" /></a><br /></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><span style="font-size:130%;">Step 5 - On the second screen you need to choose the file you want to convert. Since you have already added the file to the play list, you need not open your file system again. Just select "Existing play list item" and on the list, select the file. Click Next.</span><br /><br /><br /></span></span><span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiirgwTOgebr21BL6_t-_E8l_4GYwEI45iZiW3-F66-KA0jXlpOGA7xt_QKTjYDAFVn6HdoL5gCrQp8X9TcCkpKP4wWkjk313iwv6igHzgSY9y-qJDRp-tbUEUUoghvBDfVZtc8T5q-fFw/s1600-h/SecondScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiirgwTOgebr21BL6_t-_E8l_4GYwEI45iZiW3-F66-KA0jXlpOGA7xt_QKTjYDAFVn6HdoL5gCrQp8X9TcCkpKP4wWkjk313iwv6igHzgSY9y-qJDRp-tbUEUUoghvBDfVZtc8T5q-fFw/s400/SecondScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285084578538306" border="0" /></a><br /></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><span style="font-size:130%;">Step 6 - Check both the boxes and select the format you want to convert it to from the drop down list. Choose the bit rates. The output file size will depend heavily on this. Experiment with different settings to get the proper mix of quality and size. Click Next.</span><br /></span></span><span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlH8Gpw3K33-iRzne5ALwAQDKVPPkIskCkRDzQRQPOxSTZRshPr4R_rPpEuo-TTeHSDO1dcemYdoguIu5FPROTIqT7_fBIA6A3AT8gQfUtzBR4KYA9LFUxaWIjahcYr3PBZ2TyiBNQeT4/s1600-h/ThirdScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlH8Gpw3K33-iRzne5ALwAQDKVPPkIskCkRDzQRQPOxSTZRshPr4R_rPpEuo-TTeHSDO1dcemYdoguIu5FPROTIqT7_fBIA6A3AT8gQfUtzBR4KYA9LFUxaWIjahcYr3PBZ2TyiBNQeT4/s400/ThirdScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285088873505618" border="0" /></a><br /></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><span style="font-size:130%;">Step 7 - You don't have anything to do on the next this screen. Just click next.</span><br /><br /></span></span><span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5-VjJQmX7L-ek7d3OIz6O3Obsm8RtghOkuOYn8_S1QyoHpRE_ftwFBMrCvl_rulL9J95KGZZ7HjbsGiCkNbzSBWMy8fZ-OJY_pGkGvR0jOYNVqSfybRZWsLwoQNeA6hfOwekCzudPxnU/s1600-h/FourthScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5-VjJQmX7L-ek7d3OIz6O3Obsm8RtghOkuOYn8_S1QyoHpRE_ftwFBMrCvl_rulL9J95KGZZ7HjbsGiCkNbzSBWMy8fZ-OJY_pGkGvR0jOYNVqSfybRZWsLwoQNeA6hfOwekCzudPxnU/s400/FourthScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285088873505634" border="0" /></a><br /></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><br /><span style="font-size:130%;">Step 8 - In this screen, click choose and specify a location where you want to save the output file. This is important. If you don't specify a file name and a location, VLC will not save it anywhere. It will just keep it in the RAM and you can see it only on the play list. Also, while specifying a file name, type in its extension also. Though you can do this later by renaming this output file with its extension. Clicking finish will start the conversion process which you can see on the main VLC window on the<br /></span></span></span><span style="font-weight: bold;font-size:100%;" ><span style="font-family:lucida grande;"><span style="font-size:130%;"> status area.</span><br /><br /></span></span><span style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh92YsB1Kl_5OJOm7hX3gXcZNuj5RmKj5wme-zpNkBtw4ivD3lbpDpSqEwh9Kiukxrw_T_SO8BataImt4suUBt_PjFpxTd0ad3K0wQpzpAdyoa06ahyphenhyphenD3na611Ij0kqTpKBu5c8DOI3IVc/s1600-h/FifthScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh92YsB1Kl_5OJOm7hX3gXcZNuj5RmKj5wme-zpNkBtw4ivD3lbpDpSqEwh9Kiukxrw_T_SO8BataImt4suUBt_PjFpxTd0ad3K0wQpzpAdyoa06ahyphenhyphenD3na611Ij0kqTpKBu5c8DOI3IVc/s400/FifthScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285093168472946" border="0" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1dkymHU07B5mbws9yzWsZNup7mbQBAA11uwi89d8se0csp8oDOMucFkzM7QV0Ku29sXKxei7BB2jnpybpJYlRU5LfypLt2d8ShD3VBAoruyG_7M_XTu3TD5YSZ6Bv5u_wSnWLec7z9hM/s1600-h/SixthScreen.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1dkymHU07B5mbws9yzWsZNup7mbQBAA11uwi89d8se0csp8oDOMucFkzM7QV0Ku29sXKxei7BB2jnpybpJYlRU5LfypLt2d8ShD3VBAoruyG_7M_XTu3TD5YSZ6Bv5u_wSnWLec7z9hM/s400/SixthScreen.gif" alt="" id="BLOGGER_PHOTO_ID_5164285810428011394" border="0" /></a><span style="font-size:180%;"><br /></span></span><span style="font-weight: bold;"><span style="font-size:85%;"><span style="font-family:lucida grande;"><span style="font-size:100%;"><span style="font-size:180%;">After the transcoding is complete, you new file is ready to be played. congrats.....<br /><br />This is one of the hundreds of things(I mean it...100) that VLC can do. Keep exploring.<br /></span><br /><br /></span><br /></span></span></span>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com0tag:blogger.com,1999:blog-8523387337063744412.post-61120034761837594132008-01-16T22:22:00.000+05:302008-01-16T22:34:01.579+05:30Why Cry over VISTA???<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9P7CfMh-v655Qq75HfekMQeF7aNKWRufpPdzL-k61fx75TKUyrFEZiLNGJMVshiJbBIjod1xLzIb5qTRrB72H2UYaDOD6BlZOFF9idOz2ZlDDBB2LFhdzfEn3LkQp_mQL41mElcaIqQ/s1600-h/Vista+3.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgR9P7CfMh-v655Qq75HfekMQeF7aNKWRufpPdzL-k61fx75TKUyrFEZiLNGJMVshiJbBIjod1xLzIb5qTRrB72H2UYaDOD6BlZOFF9idOz2ZlDDBB2LFhdzfEn3LkQp_mQL41mElcaIqQ/s200/Vista+3.jpg" alt="" id="BLOGGER_PHOTO_ID_5156120945742728978" border="0" /></a><br /><span style="font-weight: bold;font-size:85%;" >I have read a lot of feedbacks about Vista all over the Internet, and I found almost 98% of them cursing this poor Operating System. Before buying my HP laptop, I insisted on getting an XP version of windows to be installed on my machine. But I was told that this particular model of mine cannot run any old version of Windows, which is true. I was furious then. I thought, how can Microsoft decide which OS should I be using. I even tried installing XP on my machine, but without any success. I really don't understand the reason why I cannot do this. I thought of installing Xubuntu, a Linux based OS, but then as I have heard from so many people of the problems it might cause to my other partitions, I was a bit reluctant. On many occasions, I have seen people crying over their lost data in the process of experimenting with their Operating Systems. With Vista, I didn't want to take any chances.<br /></span><br /><span style="font-weight: bold;font-size:85%;" >So, I wrote to the manufacturer of my laptop asking them this weird question. "Can I install Linux as a second OS on my laptop which is already running on Windows Vista? And where do I get the drivers for all my devices for Linux".<br /><br />The reply I got was,<br />"Your laptop is designed to work with Vista only. You might not even be able to install XP. And regarding the drivers for Linux, you won't find them anywhere. We don’t support Linux as yet. The best thing we can suggest if you plan to install Linux is to BACK UP YOUR DATA FIRST.</span><br /><span style="font-weight: bold;font-size:85%;" ><br />We will inform you once the drivers for Linux are available.<br /><br />Do let us know your experience since no one else has ever came up with this query. Your feedback might help us to help others."<br /><br />WOW....I was both happy and disappointed with their reply. "Happy" because, I consulted them before taking that would-have-been fateful step, and disappointed because, there were no drivers for Linux. And without the drivers, I wouldn't get the optimal performance with Linux. So, what’s the point of even trying? This goes for Windows XP as well.<br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLFHfl6l-_K-QF09C1iTQQjU3AvQm0mOiPMRMkRW_0eRSgRFss5Q3iNyhd-cZtW9TdpqpRhC79-Z4Ve0jQR3fHvqc3YsyekCoqGsWtjkb4Awy7rqn-MmGI7ROKT41sma15XodimyLfviE/s1600-h/Vista+2.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLFHfl6l-_K-QF09C1iTQQjU3AvQm0mOiPMRMkRW_0eRSgRFss5Q3iNyhd-cZtW9TdpqpRhC79-Z4Ve0jQR3fHvqc3YsyekCoqGsWtjkb4Awy7rqn-MmGI7ROKT41sma15XodimyLfviE/s200/Vista+2.jpg" alt="" id="BLOGGER_PHOTO_ID_5156120941447761666" border="0" /></a><br /><span style="font-weight: bold;font-size:85%;" >By the time I decided not to play with my laptop as far as the OS was concerned, it had already been a year with my Laptop and Vista. And I have no major complaints. There were some minor problems which I had in the beginning, but when I kept updating my OS with the free updates being released by Microsoft almost every day, those problems seem to have vanished, quite surprising, isn't it?<br /><br />The first few weeks with Vista were the most difficult ones. On the fourth day of my Laptops Life, Vista crashed. Fortunately, I had my recovery CDs with me. Didn't lose much data then. I had once more crash after about a month when I lost all my data. I was now getting terrified of it. The Recovery CDs helped me again.<br /><br />Now, it’s been 1 whole year, and except for the 2 hiccups in the early days, I have had a very pleasant experience with My Vista.<br /><br />The one problem with vista, which so many people complain about, is that it's a resource hog. I don't understand why people feel so. My Laptop came with a mere 512MB RAM. But I had upgraded it by adding one 1GB of RAM. That was the max I could have done. So with 1.5GB of RAM, I have never seen the used memory going beyond 800MB. Of course, 512MB wasn't enough, but if you want to buy a laptop today, the minimum RAM that any average model will be providing would be at least 1GB. With 1GB of RAM, Vista would never stall (At least the Home versions).<br /><br />Come on guys!!!! Vista is a baby now, just launched. It will surely grow up to be stable and one of the best OSes that Microsoft has come up with. I would suggest you to regularly update your OS from Microsoft. These will surely help you raising this little baby into a cute and charming boy. I can't compare it with Linux or MAC, since I haven't had long experiences with them. I have never seen any MAC OSes, but have heard about its brilliance. I have definitely seen and used Linux, the most recent versions as well, and I would give both of them 9 out of 10 (Linux and Vista).<br /><br /></span>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com1tag:blogger.com,1999:blog-8523387337063744412.post-42820459460094276282007-10-22T23:20:00.001+05:302007-10-23T00:09:42.063+05:30Flex 2 - Read from MS Excel<span style="font-size:85%;">As we know that Flex 2 cannot connect to any database directly, we do so by using Web Services, or writing</span><span style="font-size:85%;"> assemblers that connect to the database and return results in XML form. This can become a tedious task especially when there's not much data to be maintained, where a simple CSV file created in MS Excel would suffice. With this example, I will show how to extract data from a CSV file and p</span><span style="font-size:85%;">opulate it onto a DataGrid element.<br /></span><br /><span style="font-size:100%;">Step 1: Create a CSV file.</span><br /><span style="font-size:85%;"><br />Open Microsoft Excel and prepare the following structure with three fields or columns.<br /></span><br /><span style="font-size:85%;">Name Phone Country</span><br /><span style="font-size:85%;"><br />And enter some values for these fields. While saving the file, in the file type, change it to CSV format. We will</span><span style="font-size:85%;"> name this file as TextExcel.</span><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/__9PneCDHGgs/RxzjpCMaBPI/AAAAAAAAANA/oqh0VHdheNg/s1600-h/ExcelScreenshot.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/__9PneCDHGgs/RxzjpCMaBPI/AAAAAAAAANA/oqh0VHdheNg/s320/ExcelScreenshot.gif" alt="" id="BLOGGER_PHOTO_ID_5124220770143831282" border="0" /></a><br />Step 2: Create a Flex 2 project with the following structure.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/__9PneCDHGgs/RxzkFSMaBQI/AAAAAAAAANI/WKBGKZfGdnQ/s1600-h/Project+Structure.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/__9PneCDHGgs/RxzkFSMaBQI/AAAAAAAAANI/WKBGKZfGdnQ/s320/Project+Structure.gif" alt="" id="BLOGGER_PHOTO_ID_5124221255475135746" border="0" /></a><br /><span style="font-size:85%;">Now copy the CSV file that you have created into this project folder.</span><br /><span style="font-size:85%;">Create a DataGrid inside a Panel with three columns. We will add a button "Read" which when clicked will read the CSV file and set the values in the DataGrid.<br /><br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNOGWdxor8h7PV4s04QIfwSO9BDA4sKmllYum6xAVcy6TK79o9LV6AYN1lOztshqybdoxo1jRk1sWOQSekFcDhXcdZh59w7eVonJvqVneh_SGSkPOgFIZBsBg7Ebj_BJtlzJtcHoRG9Rw/s1600-h/Code+1.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNOGWdxor8h7PV4s04QIfwSO9BDA4sKmllYum6xAVcy6TK79o9LV6AYN1lOztshqybdoxo1jRk1sWOQSekFcDhXcdZh59w7eVonJvqVneh_SGSkPOgFIZBsBg7Ebj_BJtlzJtcHoRG9Rw/s320/Code+1.gif" alt="" id="BLOGGER_PHOTO_ID_5124228986416268578" border="0" /></a><br /><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1">Now, we need to write a fucntion called readExcel which will read the CSV file and populate the DataGrid.<br /><br /><br /></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbcS7ezPRMwXBZnpupLYG37DKZlSdjx3FJpNxLsCbPjU001IOj2TGGuB3kAVWT_kxn8z_ZnLcCv3ESvai6jrzgFk70EAuFQdz4oDjh-v6AXlgALbsiM0grDWkW5SVv34o53qX7z4pR6k/s1600-h/Code2.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDbcS7ezPRMwXBZnpupLYG37DKZlSdjx3FJpNxLsCbPjU001IOj2TGGuB3kAVWT_kxn8z_ZnLcCv3ESvai6jrzgFk70EAuFQdz4oDjh-v6AXlgALbsiM0grDWkW5SVv34o53qX7z4pR6k/s320/Code2.gif" alt="" id="BLOGGER_PHOTO_ID_5124229398733129010" border="0" /></a><br /><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1">Make a note of the import statements which you need to write before you cab access the URLRequest, URLLoader classes.</mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><br /><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1">To the loader object, we have associated two event handlers, for which methods need to be written as well. The Event.COMPLETE will contain most of the code needed. We can do away with the other event, if we can be sure that there will never be an IO_ERROR, i,e. we are always able to access the CSV file.<br /></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><br /><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1">The code for the Event.COMPLETE method - eventComplete and for the Event.onIOError - onIOError<br /><br /><record.length; obj="new" fields="record[i].split(",");" col1="fields[0];" col2="fields[1];" col3="fields[2];" dataprovider="records;" read="" content="" passed="" on="" variable="" result="" as="" single="" so="" split="" string="" create="" d="" that="" contain="" structure="" spliting="" creating="" records="" final="" step="" will="" be="" setting="" this="" array="" datagrid="" s="" and="" code="" for="" onioerror="" private="" function="" i="" o="" error="" now="" we="" are="" all="" set="" run="" when="" browser="" opens="" you="" just="" have="" click="" button="" to="" show="" up="" data="" in="" here="" is="" a="" screenshot="" of="" the=""></record.length;></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1"><record.length; obj="new" fields="record[i].split(",");" col1="fields[0];" col2="fields[1];" col3="fields[2];" dataprovider="records;" read="" content="" passed="" on="" variable="" result="" as="" single="" so="" split="" string="" create="" d="" that="" contain="" structure="" spliting="" creating="" records="" final="" step="" will="" be="" setting="" this="" array="" datagrid="" s="" and="" code="" for="" onioerror="" private="" function="" i="" o="" error="" now="" we="" are="" all="" set="" run="" when="" browser="" opens="" you="" just="" have="" click="" button="" to="" show="" up="" data="" in="" here="" is="" a="" screenshot="" of="" the=""><br /></record.length;></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1v_WACqslSujn8vIxfH0ipGIB0O6LbdMKxG7AB6VAVE3lKSQx-KQvZLWSS7qCu0nQLQqIAat1xTVc0fNKI0_gVYFucjYa3W0sujyKUaseTo8EyM9A_WcZU9-2dwkgKb8l8Ws9vY1tsSE/s1600-h/Code3.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1v_WACqslSujn8vIxfH0ipGIB0O6LbdMKxG7AB6VAVE3lKSQx-KQvZLWSS7qCu0nQLQqIAat1xTVc0fNKI0_gVYFucjYa3W0sujyKUaseTo8EyM9A_WcZU9-2dwkgKb8l8Ws9vY1tsSE/s320/Code3.gif" alt="" id="BLOGGER_PHOTO_ID_5124229922719139138" border="0" /></a><span style="font-size:85%;"><mx:panel x="20" y="25" width="466" height="312" layout="absolute"><mx:datagrid x="10" y="10" width="416" id="datagrid"><mx:columns><mx:datagridcolumn headertext="Name" datafield="col1"><record.length; obj="new" fields="record[i].split(",");" col1="fields[0];" col2="fields[1];" col3="fields[2];" dataprovider="records;" read="" content="" passed="" on="" variable="" result="" as="" single="" so="" split="" string="" create="" d="" that="" contain="" structure="" spliting="" creating="" records="" final="" step="" will="" be="" setting="" this="" array="" datagrid="" s="" and="" code="" for="" onioerror="" private="" function="" i="" o="" error="" now="" we="" are="" all="" set="" run="" when="" browser="" opens="" you="" just="" have="" click="" button="" to="" show="" up="" data="" in="" here="" is="" a="" screenshot="" of="" the="">When we read the CSV, all of the content is passed on to the variable result as a single String constant. so we have to split the string and create a 2-D array(records) that will contain the structure of the DataGrid.<br /><br />When the spliting and creating of the records array is done, the final step will be setting this array to the Datagrid's dataProvider.<br /><br />And we are done!!!!.<br /><br />Now we are all set to run the project. When the browser opens up, you just have to click the button to show up the data in the DataGrid. Here is a screenshot of the ouput.<br /><br /><span style="font-size:100%;"><span style="font-weight: bold;">NOTE : If you are not able to see the code in the pictures, click on the image and it will open up in a new window.</span></span><br /><br /><br /></record.length;></mx:datagridcolumn></mx:columns></mx:datagrid></mx:panel></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/__9PneCDHGgs/RxzkqCMaBRI/AAAAAAAAANQ/GTUNP75i6u0/s1600-h/Broser.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/__9PneCDHGgs/RxzkqCMaBRI/AAAAAAAAANQ/GTUNP75i6u0/s320/Broser.gif" alt="" id="BLOGGER_PHOTO_ID_5124221886835328274" border="0" /></a>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com5tag:blogger.com,1999:blog-8523387337063744412.post-81416302048609812562007-10-18T22:43:00.000+05:302007-10-18T23:24:15.808+05:30Flex 2 - Read local File<span style="font-size:100%;">This is a simple Flex 2 project that reads data from a local file and displays it on a text area on the click of the Fetch Data button. There are different ways in which you can capture data from a file, i.e, in simple String variable, an XMLDocument etc.<br /><br />There's a trick to mention the URL of the file when the Data.txt file is not in the same folder as the main .mxml file. For example, if your file is in a folder called News, then the URLRequest should contain the location of the file like this:<br /></span><span style="font-size:100%;"><br />"./News/Data.txt". Ofcourse, the News folder should be in the same domain. If you need to access a file in another domain, you will have to make a cross-domain file. This I will be discussing later.</span><br /><span style="font-size:100%;"><br />The project structure should be like this for the below code to work:</span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisORHFnYiZDOoUJC9LKuAtUHGQlB2IPhdRB0qw54cbuh_2rQzf4KDXCyxwiytrzA7_B8AUy1C9JoywxIKimktS-0Ot-6I53OwwNFIU1PGATVZYFeoT1z9n_phNFAyanm0nF5CpT4mN4lo/s1600-h/Project+Structure.gif"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEisORHFnYiZDOoUJC9LKuAtUHGQlB2IPhdRB0qw54cbuh_2rQzf4KDXCyxwiytrzA7_B8AUy1C9JoywxIKimktS-0Ot-6I53OwwNFIU1PGATVZYFeoT1z9n_phNFAyanm0nF5CpT4mN4lo/s200/Project+Structure.gif" alt="" id="BLOGGER_PHOTO_ID_5122730236103492802" border="0" /></a><br /><br /><span style="font-size:100%;"><br /></span><span style="font-size:85%;"><span style="font-size:100%;">This example shows a simple Data.txt file being read.</span><br /><mx:application style="font-weight: bold;" mx="http://www.adobe.com/2006/mxml" layout="absolute"><br /><mx:script><br /><!--[CDATA[ import mx.controls.Text; import mx.controls.Alert; import mx.controls.DataGrid; private var result:XML=new XML(); private var output:XMLDocument; private function fetchData():void{ var url:URLRequest = new URLRequest("Data.txt"); var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE,populate); loader.addEventListener(Event.OPEN,open); loader.load(url); result = loader.data; } private function populate(event:Event):void{ var loader:URLLoader=URLLoader(event.target); var result:String = loader.data; textArea.text = result; } private function open(event:Event):void{ } private function clearText():void{ textArea.text = ""; } ]]--><br /></mx:script></mx:application></span> <span style="font-size:85%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"></mx:panel></mx:application></span><span style="font-size:85%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><span style="font-size:100%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:script><!--[CDATA[ import mx.controls.Text; import mx.controls.Alert; import mx.controls.DataGrid; private var result:XML=new XML(); private var output:XMLDocument; private function fetchData():void{ var url:URLRequest = new URLRequest("Data.txt"); var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE,populate); loader.addEventListener(Event.OPEN,open); loader.load(url); result = loader.data; } private function populate(event:Event):void{ var loader:URLLoader=URLLoader(event.target); var result:String = loader.data; textArea.text = result; } private function open(event:Event):void{ } private function clearText():void{ textArea.text = ""; } ]]--></mx:script><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:button x="10" y="157" label="Fetch File" id="fetchFile" click="fetchData()"><mx:button x="282" y="157" label="Clear" click="clearText()"></mx:button></mx:button><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:script></mx:script><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:button x="10" y="157" label="Fetch File" id="fetchFile" click="fetchData()"><mx:button x="282" y="157" label="Clear" click="clearText()"></mx:button></mx:button></mx:textarea></mx:panel></mx:application></mx:textarea></mx:panel></mx:application></span><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:script></mx:script><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:button x="10" y="157" label="Fetch File" id="fetchFile" click="fetchData()"></mx:button><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"></mx:application></mx:textarea></mx:panel></mx:application></mx:application></mx:textarea></mx:panel></mx:application></span><span style="font-size:85%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><span style="font-weight: bold;">THE OUTPUT:<br /></span></mx:textarea></mx:panel></mx:application></mx:textarea></mx:panel></mx:application></span><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3MauyMqmX5K9hMCGkRq53epTNToa8AD1JsXJDyqMlvPyhFs2Aa0gEwiEBqZlTqQTxQCNnseBLkJUQXNTEfIKc_6XRWK-eGZhnc2VphaKqiPKvO9YW0OaeV6APdfRnbUeXVqrILr7R12w/s1600-h/Output.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3MauyMqmX5K9hMCGkRq53epTNToa8AD1JsXJDyqMlvPyhFs2Aa0gEwiEBqZlTqQTxQCNnseBLkJUQXNTEfIKc_6XRWK-eGZhnc2VphaKqiPKvO9YW0OaeV6APdfRnbUeXVqrILr7R12w/s320/Output.gif" alt="" id="BLOGGER_PHOTO_ID_5122730837398914258" border="0" /></a><span style="font-size:85%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><span style="font-weight: bold;">SOURCE CODE<br /></span></mx:panel></mx:application></span><span style="font-weight: bold;">Listing of LocalFileRead.mxml</span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSRbrTh3FimrRuMIi8wzTNeZHMd7f-xZH-TtiZPXKkPSAJnqb8SeLfFsjFbt3e5OaMo2usBw6HVNXd3gMzJWe2e-UoBHWNSR-I1KYKzige4-OBAZvf5d7U7htID1JZqtv6nsftQkviFaI/s1600-h/SourceCode.gif"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSRbrTh3FimrRuMIi8wzTNeZHMd7f-xZH-TtiZPXKkPSAJnqb8SeLfFsjFbt3e5OaMo2usBw6HVNXd3gMzJWe2e-UoBHWNSR-I1KYKzige4-OBAZvf5d7U7htID1JZqtv6nsftQkviFaI/s400/SourceCode.gif" alt="" id="BLOGGER_PHOTO_ID_5122735334229673186" border="0" /></a><span style="font-size:85%;"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:button x="10" y="157" label="Fetch File" id="fetchFile" click="fetchData()"><mx:button x="282" y="157" label="Clear" click="clearText()"><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"><mx:textarea x="10" y="10" width="327" height="139" id="textArea"><mx:button x="10" y="157" label="Fetch File" id="fetchFile" click="fetchData()"><mx:button x="282" y="157" label="Clear" click="clearText()"></mx:button></mx:button><mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute"><mx:panel x="10" y="10" width="715" height="309" layout="absolute" id="panel" label="Test Panel" title="Test Panel"></mx:panel></mx:application></mx:textarea></mx:panel></mx:application></mx:button></mx:button></mx:textarea></mx:panel></mx:application></mx:textarea></mx:panel></mx:application></span>Anonymoushttp://www.blogger.com/profile/16335275017896132892noreply@blogger.com3