How To Get IP Address In Java

java-thumbnail

This is simple example to demonstrate the use of InetAddress.getLocalHost() API to retrieve the IP Address details of your local system or where ever the Java program is executed. If you write a server applications, this can be used for getting the server’s IP Address. Lets look at the example code to display the IP Address […]

How To Get Free Disk Space In Java (Windows)

java-thumbnail

This simple Java program helps you to get the free disk space on your windows machines. Here I have used three methods for getting the disk space from your system. getTotalSpace() getUsableSpace() getFreeSpace() The above methods are introduced from Java 6.0 and as part of the java.io package. The below example prints the disk space […]

How To Test Internet Connection Using Java

java-thumbnail

It is very often required to test the internet connection for performing some operations. If there is no internet connection established, then alternative logic will be executed. Java provides useful classes in java.net package for connecting to the internet. Here I written a very simple example to test if your system is connected to internet. […]

How To Check Network Connection Using Java

java-thumbnail

It if often required to get the details of the network connection in your desktop. It will be useful if you could get the details of all the connected network details for the future operations. Java has set of classes in the java.net package which is useful for the Java network programming. In this example […]

How To Get OS In Java

java-thumbnail

This post writes a simple Java example program  to get the current operating system. There is a system property in Java, System.getProperty(“os.name”) which returns the operating system. However, this utility returns the operating system type like Windows, Mac, Unix or Linux. Lets look at the below example. GetOSExample.java Output…

File Modified Date Manipulation in Java

java-thumbnail

This example demonstrates the basic data manipulation operation in a File object. Java File object has set of methods to perform the following operations: Get the file last modified date Change the file modified date Lets look at the example to see how the above operations are implemented in Java example program. We use SImpleDateFormat […]

How To Set The File Permissions In Java

java-thumbnail

Setting the file permissions in Java is OS specific. Each type of file system have different kind of file systems. Java provides the very generic solution to set the file permissions for all kind of file systems. This example demonstrates how to set file permissions to a file in the Linux operating system using Java […]

Convert InputStream To String In Java

java-thumbnail

In my previous example, I have written a simple program to covert string object to InputStream. This tutorial does the reverse, converting inputstream into a string object. Lets look at the example.

Convert String To InputStream In Java

java-thumbnail

This is simple exmaple for converting string object to a InputStream and then read it using the BufferedReader.

How To Delete Temporary File In Java

java-thumbnail

In my previous article I have explained about how to create and write into a temporary file. Normally this file will be deleted once the operation is completed. Lets look at this simple example, to understand getting the temporary file path and deleting it on exit of the program. Delete Temporary File Example Output…