Skip to main content

Posts

20 very useful Java code snippets for Java Developers

Following are few very useful Java code snippets for Java developers. Few of them are written by me and few are taken from other code reference. Feel free to comment about the code and also add your code snippet. 1. Converting Strings to int and int to String String a = String.valueOf( 2 );   //integer to numeric string int i = Integer.parseInt(a); //numeric string to an int 2. Append text to file in Java Updated: Thanks Simone for pointing to exception. I have changed the code. BufferedWriter out = null ; try {      out = new BufferedWriter( new FileWriter(”filename”, true ));      out.write(”aString”); } catch (IOException e) {      // error processing code } finally {      if (out != null ) {          out.close();      } } 3. Get name of current method in Java Stri...

Android is not Google and Google is not Android anymore?

I like Android a lot. It’s Linux’s biggest end-user success story. Android has great applications. Moreover, Android’s smartphone market-share is growing fast. Eventually Android will become the number one smartphone operating system in the world. If, that is, everything goes right. Android’s biggest worry is not the iPhone, the Blackberry, or Windows Phone 7; it is that it will fragment into multiple incompatible, brand-specific versions. With a large number of custom versions of the Android platform emerging, the concern is that interoperability will be weakened because of the potential for applications built specifically for one variant or device not being able to work with others. You see, all the original equipment manufacturers (OEMs), like Motorola and HTC put their own software, Sense UI and Motoblur respectively, on top of Android. Then, all the carriers add their own special-sauce of applications. It can get messy. If the makers of the number one mobile game in the worl...