FileStore in Java 7

java-thumbnail

FileStore is new class introduced in Java 7.0. It is part of java.nio package. This class helps in geting the type of storage for the files stored whether it’s a device, partition or concreate file system. Also this class defines the list of methods which is useful for getting information about the file storage such […]

How To Convert String To Byte In Java?

java-thumbnail

This tutorial highlights the simple example to demonstrates how to convert a string object to the byte stream. We can simply use the getBytes() method in the string object to convert the string to bytes array. Lets look at the example program. Output

How To Convert Char To String In Java?

java-thumbnail

This post highlights a simple example to demonstrates how to convert a char datatype to a string object. Lets look at the example program. Output

How To Convert String To Char Array In Java?

java-thumbnail

This tutorial is simple example for converting a string object into a simple character array. Lets look at the example. Output…  

How To Convert Char Array To String In Java?

java-thumbnail

This tutorial is simple example for converting a character array into a simple string object. In general, there are two ways to convert the character array to string object, First approach is to pass the array into the string constructor and second approach is to using the String.valueOf(). Lets look at the example. Output…

StringTokenizer Example

java-thumbnail

StringTokenizer in java.util package is very useful for spliting the length string into the pieces. You can pass a delimeter to the StringTokenizer constructor to split the string where ever that delimeter appeared in the string. If you have not passed any delimeter, by default it splits the string using the empty space in the […]

Compressing and Uncompressing File Example in Java

java-thumbnail

Compressing and Uncompressing of the files is one of the common utility we use in our daily life. If you are using windows, using WinZip is very common to compress the files and sent to others. The advantage of compressing the files is to save the memory occupied for the file in the disk. It […]

TreeSet in Java

java-thumbnail

TreeSet class implements the Set interface and stores the data in tree structure. The values are stored in sorted and ascending oreder. It is quite fast in retrieval of elements. This makes TreeSet is most prefered choice for storing the large amount of data in sorted order and want to retrieve it fast. This supports […]

How To Sort Java Object Using Comparable And Comparator?

java-thumbnail

This tutorial shows how to use java.util.Comparator and java.lang.Comparable to sort a Java object based on its property value. Here I have created Employee object with Name and Age properties, we will be able to sort the list of objects based on the values in the property’ Lets look at the example. Employee.java ComparatorExample.java Output […]

HashTable in Java

java-thumbnail

HashTable class was originally added as part of java.utill package and extended the Dictionary class. From Java 2, it is re-engineered to implement the Map interface and made as part of the collections framework. HashTable is similar to HashMap except that HashTable is synchronized. It is very much similar to HashMap, stores the key-value pairs. […]