-3

I would like to write a Java Programm which should be able to create a Folder in Windows, but the Client should be a able to decide on the Name of the Folder. How can I do that?

Thanks for any suggestions!

LCP
  • 45
  • 1
  • 3
  • 10
  • with an input in the type of `String` and by using the [File](https://docs.oracle.com/javase/7/docs/api/java/io/File.html) or [Files](https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html) class – SomeJavaGuy Nov 24 '16 at 14:24

2 Answers2

0

A small google search would have given you the answer. If you want to name it a specific way, just grab the name from a JTextField or something like that.

Community
  • 1
  • 1
skw
  • 516
  • 7
  • 19
0

Create a File object and use mkdir() to create a new folder.

File folder;
folder = new File("path/to/new/folder");
folder.mkdir();

Obviously you will need to check if the folder already exists and you will need to use an inputted string for the name of the folder.