This post demonstrates a simple example for how to compress your file and add to the ZIP file. Java has built-in API java.util.zip for compressing the files in ZIP format. It is very simple to read the files from your disk and writing to the destination ZIP file. It is straight forward. The steps involved …
Java Basics
FileStore in Java 7
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?
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?
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?
This tutorial is simple example for converting a string object into a simple character array. Lets look at the example. Output…
StringTokenizer Example
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
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 …
How To Sort Java Object Using Comparable And Comparator?
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 …