To create a directory in Java, uses the following code :
1. Create a single directory.
2. Create a directory named “Directory2 and all its sub-directories “Sub2″ and “Sub-Sub2″ together.
Both methods are returning a boolean value to indicate the operation status : true if succeed, false otherwise.
1. Create a single directory.
new File("C:\\Directory1").mkdir();
new File("C:\\Directory2\\Sub2\\Sub-Sub2").mkdirs()
Example
A classic Java directory example, check if directory exists, if no, then create it.package com.mkyong.file; import java.io.File; public class CreateDirectoryExample { public static void main(String[] args) { File file = new File("C:\\Directory1"); if (!file.exists()) { if (file.mkdir()) { System.out.println("Directory is created!"); } else { System.out.println("Failed to create directory!"); } } File files = new File("C:\\Directory2\\Sub2\\Sub-Sub2"); if (files.exists()) { if (files.mkdirs()) { System.out.println("Multiple directories are created!"); } else { System.out.println("Failed to create multiple directories!"); } } } }
Both methods are returning a boolean value to indicate the operation status : true if succeed, false otherwise. gul ahmed lawn , lawn suits online shopping , lawn dresses online , pakistani designer lawn suits , pakistani cotton suits online , lawn collection , lawn suit design , new lawn collection , unstitched suits pakistani , lawn suits with prices
ReplyDeletenike shox for men
ReplyDeletenike foamposite
nike vapormax
supreme
yeezy shoes
off white clothing
supreme
ferragamo belt
balenciaga shoes
adidas zx flux
Ysl replica p15 x9c16h6h89 replica bags online b54 i5j17z3s59 designer replica luggage d05 l1m71d4q56
ReplyDelete