I want to open a source file for my custom ant task. I thought this would be easy, because surely the class loader get resource would immediately find the source file for me. Wrong!
Here’s my code:
//build the name of the template
StringBuilder sb = new StringBuilder(VersionTemplate.class.getName());
sb.append(".java");
String templateName = sb.toString();
//find the template
InputStream inputStream = VersionTemplate.class.getResourceAsStream(templateName);
inputStream is always null.
Any ideas?
It occurred to me after the fact that getResource() looks on the class path, which is not where the source code is. I ended up simply just coding a relative path to the code.
Thanks for the help.