简体   繁体   English

通过Java中正在运行的程序创建文件

[英]Creating files through a running program in java

I have a button on my game and when the game is running there is a button. 我的游戏上有一个按钮,当游戏运行时,有一个按钮。 I want to know if theres a way to create folders within the projects file stream if the user clicks the button. 我想知道是否有一种方法可以在用户单击按钮的情况下在项目文件流中创建文件夹。 So to be more precise, what code do I need to create a folder within the project(not locally) ? 因此,更确切地说,我需要在项目(而非本地)中创建文件夹的什么代码?

You can create a directory like so: 您可以这样创建目录:

boolean success = new File("../some/path/to/my/directory").mkdirs();

The above, will also create the directory ancestry. 上面,还将创建目录祖先。 see File.mkdirs() 参见File.mkdirs()

Alternatively, you can create the directory (without ancestry) using File.mkdir() 或者,您可以使用File.mkdir()创建目录(无祖先

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM