To rename a file , use the renameTo method in java.io.File.
Java – Convert JavaBean Using XMLEncoder and XMLDecoder
This post shows how to use the Java classes XMLEncoder and XMLDecoder to convert JavaBean objects to XML and back. Note that they support the specifications for JavaBeans to make things work. On the other hand, a conversion may not
Java 8 – Convert Iterator to Stream Using StreamSupport
Although not a common scenario, some libraries return Iterators instead of Stream or Collection objects. Why? Because they can. If the Java libraries you are using have methods that return Iterator objects, this will show how to convert Iterator to
Avoid NullPointerException with Stream.ofNullable in Java 9
This post demonstrates how to avoid NullPointerException in Java 9 when working with Stream and using the overloaded of metho
Java – Create class constructor with fields faster in Eclipse
This post shows how to create a Java class constructor with fields faster in Eclipse. Before the advent of smart IDEs, Java developers write out almost all codes as it was the only way to do and IDEs were in
Java – Where can we place the public static void main method?
Many Java programmers are only familiar with having the public static void main in a class to start the application. However, there are other places where we can define this static method and still start up a Java application. This
Java – How to skip and not execute the finally clause
They say that when an Exception occurs, the finally clause, if available, will always execute no matter except for one thing.
Remove XML Element based on parameter in Java using XSLT
This post shows how to remove an XML element based on some parameters in Java using XSLT. We mean parameters for the Transformer object and let XSLT work its magic during the transformation. Therefore, three significant events will happen. First,
Java – Closing JDBC Database Resources with try-with-resources
This post demonstrates how to use Java JDBC API with try-with-resources database resources in the following order – ResultSet, Statement, and Connection. The try-with-resources is a new exception handling mechanism that makes it easier to correctly close resources used within
Chapter 7: Java Classes And Access Modifiers – Review
Java classes and their variables and methods can use access modifiers – private, public, protected, and package-level (no keyword). These access modifiers set the classes’ visibility, constructors, and instance or class variables and methods to the other parts of the