Check if Database Exists using Java

We can check if database exists using java.sql.DatabaseMetaData interface. using DatabaseMetaData interface we can obtain the meta data about the database catalog, for example we can obtain the database name, tables available in that database, columns in that table etc. The getCataLogs() method which is called on the instance of  DataBaseMetaData, retrieves the catalog name … Read more

Create JDBC Connection using Properties File

In this tutorial we will create jdbc connection using properties file. Properties file is a convenient way to store the data in key value pair. in properties file both key and values are of String type. We are storing the connection parameters in the properties file because we can manage the properties file very easily. … Read more

Configure log4j using properties file in Java

Log4j is a logging framework based on Java, It is an open source logging framework designed to manage application logs in a flexible and efficient manner. Configuring Log4j with Properties File:- One of the key features of Log4j is its easy configuration. To set up Log4j using a properties file, developers can rely on the … Read more

Get All Key Values from Properties File

Get All Key Values from Properties File Get All Key Values from Properties File in java using the Properties class Available in java.util Package. The Properties class extends the Hashtable class. From Hashtable, Properties class inherits the Method KeySet() which Returns a Set view of the keys Contained in this Map. Project Structure:- Example to … Read more

Read Properties File using java

To Read Properties File in Java, the Properties Class has a Convenient load Method. That’s the Easiest Way to Read a Java Properties File. Properties are Configuration Values Managed as key/value Pairs. In Each Pair, the key and value are Both String Values. The key Identifies, and is Used to Retrieve, the Value, much as … Read more

Network Interface Addresses Listing

We can get the list of IP addresses that are assigned to it using a network interface. Network interface addresses can be obtained from a NetworkInterface instance by using one of two methods. The first method, getInetAddresses(), returns an Enumeration of InetAddress. The other method, getInterfaceAddresses(), returns a list of java.net.InterfaceAddress instances. This method is … Read more

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