Skip to content

Instantly share code, notes, and snippets.

@yanil3500
Last active May 6, 2019 03:53
Show Gist options
  • Save yanil3500/06b090f45434852a8508a5e708320637 to your computer and use it in GitHub Desktop.
Save yanil3500/06b090f45434852a8508a5e708320637 to your computer and use it in GitHub Desktop.
Java Project Generator
import os, sys
JAVA_TEMPLATE = """
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
"""
def create_dir(*args):
if len(args) < 2:
raise ValueError("Please provide a folder name and path.")
folder_name = args[1]
path = args[2]
folder_path = '/'.join([path, folder_name])
os.mkdir(folder_path)
create_java_files(folder_path)
def create_java_files(folder_path):
file_name = 'Main.java'
full_path = '/'.join([folder_path, file_name])
a_file = open(full_path, 'w')
a_file.write(JAVA_TEMPLATE)
a_file.close()
def main():
create_dir(*sys.argv)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment