Create a New folder using Java Program on Windows and Linux machines

后端 未结 4 2051
太阳男子
太阳男子 2020-12-29 05:38

How can I create a Folder using Java code on both Windows and Linux machines?

4条回答
  •  粉色の甜心
    2020-12-29 06:07

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

    If you want to created nested folders (i.e. more than one folder on the path may be missing), then use mkdirs(). See java.io.File.

    Note that forward slashes would normally not work on windows, but Java normalizes the path and translates forward to backward slashes.

提交回复
热议问题