I'm using code such as this in our NetBeans plugin:
DataObject result = dTemplate.createFromTemplate(df, name, args);
Which generates the file correctly. However if there is a file with the given name the template occupies a new file name (as reflected in the result object) but the ${name}
value still refers to the old name. E.g. if name = Hi
and Hi.java
already exists then Hi_1.java
will be created but ${name}
will still be Hi
.
Also I'm a bit baffled regarding the source of the .java
extension. My original code had this:
DataObject result = dTemplate.createFromTemplate(df, name + ".java", args);
But it turns out the .java is unnecessary, and I'm not sure where I specify that this is indeed what I want?