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
2. Append text to file in JavaUpdated: Thanks Simone for pointing to exception. I have changed the code.
3. Get name of current method in Java
4. Convert String to Date in Java
5. Connecting to Oracle using Java JDBC
6. Convert Java util.Date to sql.Date
This snippet shows how to convert a java util Date into a sql Date for use in databases.
7. Java Fast File Copy using NIO
8. Create Thumbnail of an image in Java
9. Creating JSON data in JavaRead this article for more details.
Download JAR file json-rpc-1.0.jar (75 kb)
10. PDF Generation in Java using iText JARRead this article for more details.
11. HTTP Proxy setting in JavaRead this article for more details.
12. Java Singleton exampleRead this article for more details.
Update: Thanks Markus for the comment. I have updated the code and changed it to more robust implementation.
13. Capture screen shots in JavaRead this article for more details.
14. Files-Directory listing in Java
15. Creating ZIP and JAR Files in Java
16. Parsing / Reading XML file in JavaSample XML file.
17. Convert Array to Map in Java
18. Send Email using Java
19. Send HTTP request & fetching data using Java
20. Resize an Array in Java