📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Java creates a directory with Files.createDirectory
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class JavaCreateDirectory {
public static void main(String[] args) throws IOException {
String fileName = "/home/ramesh/tmp/newdir";
Path path = Paths.get(fileName);
if (!Files.exists(path)) {
Files.createDirectory(path);
System.out.println("Directory created");
} else {
System.out.println("Directory already exists");
}
}
}
String fileName = "/home/ramesh/tmp/newdir";
Path path = Paths.get(fileName);
if (!Files.exists(path)) {
Files.createDirectory(path);
Comments
Post a Comment
Leave Comment