The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch the Text file Using java code stored in resource folder of Jira Custom plugin .

Nishant Paraskar
December 7, 2022

How to fetch the Text file Using java code stored in resource folder of Jira Custom plugin .

 

 

Tried This Things till Now

Code : Just for Testing

     String response = "" ;

FileInputStream fis = null;
try {
response = response + "Try block" ;
fis = new FileInputStream(comments);
} catch (FileNotFoundException e) {
response = response + "Catch block :" + " "+e.toString(); ;
e.printStackTrace();
}


try {
InputStreamReader inStream = new InputStreamReader(fis);
BufferedReader buffer = new BufferedReader(inStream);




// InputStream is = FileReading.class.getClassLoader().getResourceAsStream("comments");
// BufferedReader buffer = new BufferedReader(new InputStreamReader(is));
StringBuilder builder = new StringBuilder();


response = response + "-------- Start-----";
//response = response+ " TRY BLOCK START" ;
String str;

// Condition check via buffer.readLine() method
// holding true upto that the while loop runs
while ((str = buffer.readLine()) != null) {
builder.append(str).append("\n");
}

String s = builder.toString();

s = s.replaceFirst("option1", "NNN");
s = s.replaceFirst("option2", "KKK);
System.out.println(s);


response = response + s+"-------- END-----";
}
catch (Exception e)
{
response = response + "-Exception:"+e.toString();
}

// Returning a string
return " DATA FETCH FROM FILE :"+ "|"+ "|" +response;

}

 

 

image.png

0 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.