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 online Nitin DahyabhaiFriend
Messages: 4435
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 online Nitin DahyabhaiFriend
Messages: 4435
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: Thu Apr 25 19:33:50 GMT 2024

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

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

Back to the top