Creating Folders

2 minutes
Share the link to this page
Copied
  Completed
To create a directory in Java, just use the mkdir or mkdirs methods of the Java File class.

Transcript

Hello, in this Java programming video, we are going to look at creating folders. Really simple. You want to do a import for the info the Java file module. And in here, I'm going to do swings. directory name Akali directory equals, now you specify the directory and the path as well. So we're going to specify it and say, user, for example, it's not much out there, if I do for slash users.

So the four star goes to the root user for slash, hello. And now we're going to go File, New File. And we'll need this to actually create the directory and specify the directory like So and that simply is one line we do.mk dir so make directories so this actually makes you know any parent directories that it needs to well so if I run it do nothing here for run it okay it doesn't create anything you'll need commission that will be why most likely instead what I'm going to do due to the desktop where you don't need the extra commission so do solar systems desktop. Hello under there we go directory Hello has been created. And if for example, I do Hello, that's already there. overdue Hello Well hello world and I want to create or something any creates well so if the directory doesn't exist any of the parent directory, you'll create them as well.

So that's it for, you know, making directory making folders. If you have any questions, feel free to reach out and I look forward to seeing you in the next awesome programming Java video.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.