We have 2 ways to check if file is Directory in java 1. java.io.File API’s isDirectory() method 2. java.nio.file.Files API’s [c
How to check if file is Hidden in java
To check if file is hidden in java, we use java.io.File API’s isHidden() method. In this post we will see example of how we use isHidden method i
How to get Creation Time of File in Java
To get creation time of file in java we can use the java.nio.file.Files API’s readAttributes() method. Example : Get Creation Time of File in Java [crayon-68c
How to get File size in java
We can get File size in java by 2 methods. 1. java.io.File API’s length() method 2. java.nio.file.Files API’s [crayon-68ce
How to convert ArrayList to HashSet
In this post we will see examples to convert ArrayList to HashSet in java. HashSet and ArrayList are both Collection objects. Hence we can pass ArrayList to the construtor of the HashSet and get it
How to convert ArrayList to Array
In this post we will see examples on how to convert ArrayList to Array in java. To convert ArrayList to Array we will use the toArray method from ArrayList.
1 |
public <T> T[] toArray(T[] a) |
How to create Sublist from ArrayList
To create Sublist from ArrayList in java, we need to use the subList(int fromIndex,int toIndex) method provided by ArrayList. We will see the example on how to use the subList method. [crayon-68ce7
ArrayList ensureCapacity example
If you have an ArrayList that already has lots of elements and you are trying to add more elements to the ArrayList, this may degrade the performance of the system. To improve the performance, you
How to remove elements from ArrayList
In this post we will see various ways to remove elements from ArrayList in java. ArrayList provides following methods to remove elements. 1. E remove(int index) Removes an element fr
How to add elements in ArrayList
In this post we will see various ways to add elements in ArrayList in java. ArrayList provides following methods to add elements. 1. boolean add(E e) Adds an element at the end of