Get MAC Address using Java

MAC Address can be obtained using the NetworkInterface class. This class represents a Network Interface made up of a name, and a list of IP addresses assigned to this interface. It is used to identify the local interface on which a multicast group is joined. A network interface is the point of interconnection between a … Read more

Delete All Files using Java

To delete all files using java we can simply use the delete() method available in java.io.File package. First we have to list all the file in directory using the File.listFiles() method and then simply use the File.delete() method to delete the files inside the directory. below exapmle demostrates that how to delete all files inside … Read more

Force Delete File using Java

To force delete file using Java, we can use the FileUtils or FileDeleteStrategy class available in Apache Commons Io demo to force delete file using java import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; public class ForceDelete { public static void main(String[] args){ File directory = new File(“c:\\directoryname\\filename.txt”); try { FileUtils.forceDelete(directory); System.out.println(“force delete file in java”); } … Read more

Delete File using Java API

Delete file using java with the help of delete method available in java.io.File package. The File.delete() method return boolean value. if the file is deleted successfully then the delete() method return true, on the other hand if it not able to delete file using java then it returns false. below example demonstrates how to delete … Read more

How to Get Min and Max Value of Primitive Data Types in Java

Java consists of eight primitive data types which are byte, short, int, long, float, double, boolean and char. A primitive is named by a reserved keyword and is predefined by the language. Primitive values do not share state with other primitive values. We can get the min and max value of primitive data types using … Read more

Get Current Date and Time in Java

In this post we will see that how to get current date and time in java using the class java.util.Date and java.text.SimpleDateFormat. Below is the code to get current date and time in java using Date class :- import java.text.SimpleDateFormat; import java.util.Date; public class CurrentDate { public static void main(String[] args) { Date dt = … Read more