new File("/path/directory").mkdirs();
Here "directory" is the name of the directory you want to create/exist.
Answer from Bozho on Stack Overflownew File("/path/directory").mkdirs();
Here "directory" is the name of the directory you want to create/exist.
After ~7 year, I will update it to better approach which is suggested by Bozho.
File theDir = new File("/path/directory");
if (!theDir.exists()){
theDir.mkdirs();
}
what's with a Java project folder structure ?
It depends on the build system in use for the project.
In the days of Ant or if you let the IDE set it up for you without specifying a build, it was mostly:
src/ bin/
Maven and Gradle use the Maven Standard Directory Layout ( https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html )
src
main
{lang}
packages
resources
test
{lang}
packages
resourcesYou can see that when using Gradle for groovy - https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:groovy_project_layout the lang for the groovy sources is 'groovy'. This is important if you mix groovy, scala, kotlin, and java all in one project. For example (not my project, just one I found out there) https://github.com/bellingard/sample_multi-language-project
More on reddit.comCreate directory in Javascript
Videos
So here the thing guys. I'm a data engineer by profession meaning ETL/SQL master. Recently with the explosion of new tools that hit the market in big data, I'm trying to learn Java. The challenge is, wrapping my head around Java folder structure. When I look at code in GitHub for few of the Apache projects like spark/airflow, it's so convoluted and varies by developer. Is there a rule or strategy that's developers commonly follow?
It depends on the build system in use for the project.
In the days of Ant or if you let the IDE set it up for you without specifying a build, it was mostly:
src/
bin/
Maven and Gradle use the Maven Standard Directory Layout ( https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html )
src
main
{lang}
packages
resources
test
{lang}
packages
resources
You can see that when using Gradle for groovy - https://docs.gradle.org/current/userguide/groovy_plugin.html#sec:groovy_project_layout the lang for the groovy sources is 'groovy'. This is important if you mix groovy, scala, kotlin, and java all in one project. For example (not my project, just one I found out there) https://github.com/bellingard/sample_multi-language-project
The folder structure in the src directory or of the entire project in general? Project source directory is usually driven by the convention of the build tool you're using, like gradle. The folder structure in your src directory is building the package names for your classes. The goal here is to be consistent within an organization and unique so there is little chance of ambiguity when you bring in a lot of external libraries.