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...
An ever growing website consists of top quality article collections pertaining to Latest Technology, Cool gadgets, Computers, Mobiles, Software, Guides, How-Tos, Downloads, Tips and Tricks, Virus removals, Troubleshooting, Entertainment, etc