Creating a directory path in Eclipse
The following snippet of code creates a folder structure in eclipse.
String directory = "ibn.soa.workingfolder";
String[] result = directory.split("\\.");
int k = result.length;
String e = "";
int i = 0;
while (i != k) {
e = e + result[i++] + "\\";
b = project.getFolder(".\\src\\" + e);
b.create(IResource.FORCE, true, null);
}
For example if you had the user enter something like "ibn.soa.workingfolder" and wanted to create that structure in eclipse you could use the above snippet. There are certain assumptions made, like you want it created in the src folder, but if you were looking for this kind of solution you probably know what those assumptions are by this point.
There is another way to do this using the eclipse Java Development Tooling ,JDT, framework but I didn't want to do it that way.
String directory = "ibn.soa.workingfolder";
String[] result = directory.split("\\.");
int k = result.length;
String e = "";
int i = 0;
while (i != k) {
e = e + result[i++] + "\\";
b = project.getFolder(".\\src\\" + e);
b.create(IResource.FORCE, true, null);
}
For example if you had the user enter something like "ibn.soa.workingfolder" and wanted to create that structure in eclipse you could use the above snippet. There are certain assumptions made, like you want it created in the src folder, but if you were looking for this kind of solution you probably know what those assumptions are by this point.
There is another way to do this using the eclipse Java Development Tooling ,JDT, framework but I didn't want to do it that way.
Labels: directory creation, Eclipse
6 Comments:
Any reason you don't use the pre-made functions?
What pre-made function?
How did I miss this post earlier this week?
You may have.
I mean by using the JDT framework.
SUCK IT SYED -- MY BOY'S JUST DESTROYED THE SPURS
Post a Comment
<< Home