Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Create folders (non-existent) in a given path(Eclipse Plugin generate project structure)
Create folders (non-existent) in a given path [message #1842506] Mon, 21 June 2021 22:14 Go to next message
Mukendi Mputu is currently offline Mukendi MputuFriend
Messages: 2
Registered: June 2021
Junior Member
In my project, in a generator class I'm trying to create package folders from a given string path e.g. "com/example/config". Is there way (method) I can do it quickly without splitting the string by "/" and recursively creating one folder in another?

This is what I've tried so far:
def static generateJavaPackages(String pkgName, IProject projectDir, IProgressMonitor monitor) {
		val mainJavaFolder = '/src/main/java/'

		/* create package folders */
		try {
			
			projectDir.getFolder(mainJavaFolder + pkgName).create(true, true, monitor)
			
		} catch (Exception exception) {

			exception.printStackTrace()
		}
	}
Re: Create folders (non-existent) in a given path [message #1842507 is a reply to message #1842506] Tue, 22 June 2021 00:32 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4086
Registered: July 2009
Senior Member

This is a programming
question and perhaps more appropriate for somewhere like Stack Overflow.

EDIT: removed incorrect answer


Nitin Dahyabhai
Eclipse Web Tools Platform

[Updated on: Tue, 22 June 2021 03:46]

Report message to a moderator

Re: Create folders (non-existent) in a given path [message #1842510 is a reply to message #1842507] Tue, 22 June 2021 03:38 Go to previous messageGo to next message
Mukendi Mputu is currently offline Mukendi MputuFriend
Messages: 2
Registered: June 2021
Junior Member
Thanks! I did post the question on Stack Overflow.
Re: Create folders (non-existent) in a given path [message #1842511 is a reply to message #1842510] Tue, 22 June 2021 03:49 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4086
Registered: July 2009
Senior Member

I misread your question initially. You're on the right track, you will just need to recursively check the folder's
parent to see if it exists and create it if not.


Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:Eclipse Opens, shows splash screen, then immediately crashes
Next Topic:I am getting the same output while running the JSON programs on my macbook
Goto Forum:
  


Current Time: Sun Jul 25 04:16:03 GMT 2021

Powered by FUDForum. Page generated in 0.03433 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top