Get Path File web resource

gia01020304 February 17, 2019

 I have build jira plugin rest

I add file xml in resource>config>myfile.xml in my project

I add in atlassian-plugin.xml

<resource type="download" name="myfile.xml" location="/config/myfile.xml"/>

And in my file rest.java I don't know how to get the file path

 

1 answer

1 accepted

0 votes
Answer accepted
gia01020304 February 25, 2019

I had resolved my problem by 

InputStream isStream = getClass().getResourceAsStream("filename");

After that use function

 

 public Document readFileXmlDeploy(InputStream is) throws Exception {
Document document = null;
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder;
try {
documentBuilder = documentBuilderFactory.newDocumentBuilder();
document = documentBuilder.parse(is);
} catch (Exception e) {
throw e;
}
return document;
}

Suggest an answer

Log in or Sign up to answer