How to read file using Scanner in Java

In this post we will see how to read file using Scanner in Java. Scanner is a part of the java.util package. We will use [crayon-5905c0a48f809654254666-i/] to read the file How to read file using Scanner in Java [crayon-5905c0a48f814755414266/] Reference Scanner Java

Read More

How to Copy Directory in Java Recursively

In this post we will see How to Copy Directory in Java Recursively. I have a directory “kscodes\source” and it has following folders and files inside it. Lets see an example which will copy from “kscodes\source” to “kscodes\destination” The example shows a

Read More

How to Delete Directory in Java

In this post we will see How to Delete Directory in Java. We will use the File.delete() method. But to use this method we need the directory to be empty. I have an directory “kscodes” and its has following folders and files

Read More

How to Decompress Files in Java – Zip Format

In this post we will see how to decompress files in java using ZIP format. Java provides a complete package java.util.zip to perform compression/decompression. Steps to decompress files in ZIP format 1. Create a ZipInputStream using a FileInputStream [crayon-5905c0a490b0c182231900/] 2. Read all

Read More

How to Compress Files in Java – Zip Format

In this post we will see how to compress files in java using ZIP format. Java provides a complete package java.util.zip to perform compression/decompression. Steps to compress files in ZIP format 1. Create a ZipOutputStream using a FileOutputStream [crayon-5905c0a491029776772320/] 2. Read all

Read More

How to list Files in a Directory in java

Using the [crayon-5905c0a491503434474328-i/] api we will see how to list files in a directory in java. [crayon-5905c0a49150b731592410-i/] method returns array of String containing names of files & dir’s Example:How to list Files in a Directory in java We will write a java

Read More

How to check if File is Directory in Java

We have 2 ways to check if file is Directory in java 1. [crayon-5905c0a4919d4427611204-i/] API’s [crayon-5905c0a4919dc528733060-i/] method 2. [crayon-5905c0a4919e1395248205-i/] API’s [crayon-5905c0a4919e6201359261-i/] method. 1. Example : Check If File is Directory Using isDirectory() [crayon-5905c0a4919eb624560483/] Output [crayon-5905c0a4919f1568644634/] 2. Example : Check If File is

Read More

How to check if file is Hidden in java

To check if file is hidden in java, we use [crayon-5905c0a491f77839214219-i/] API’s [crayon-5905c0a491f80250778482-i/] method. In this post we will see example of how we use isHidden method in code. Example : Check If File is Hidden [crayon-5905c0a491f85469446002/] Please Note File.isHidden() works differently

Read More

How to get Creation Time of File in Java

To get creation time of file in java we can use the [crayon-5905c0a49238b177757248-i/] API’s [crayon-5905c0a492394280737393-i/] method. Example : Get Creation Time of File in Java [crayon-5905c0a492399785364837/] Output [crayon-5905c0a4923a0947099747/] Reference 1. Files readAttributes

Read More

How to get File size in java

We can get File size in java by 2 methods. 1. [crayon-5905c0a492855632097161-i/] API’s [crayon-5905c0a49285e944813923-i/] method 2. [crayon-5905c0a492863174458394-i/] API’s [crayon-5905c0a492868352201930-i/] method. In this post we will see examples on how to get file size in java by these 2 methods. 1. Example :

Read More