#Error while reading file from src-main-resources folder
21 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @sacred stratus! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Hi friends,
I am trying to read a file from src/main/resources but it is giving me an error.
(Error: filenotfoundexception)
Attached the image of my code please help me to solve this.
Try just /price.xlsx
And no double slash
Hi @long quartz it's done with input stream I have used getResourceStream method but there is one issue after taking this input I am writing that file using OutputStream but not able to give the absolute path of /src/main/resources to create new file in it
so you want to write a new file under src/main/resources?
e.g. a new xls?
Yes I am taking one template as a input and writing a new file with all the data
Excel is created but it is not found any where
click on src/main/resources and f5?
No it's not creating in the resources folder I don't know why,but the file is generating
i think at runtime it doesn't actually run with src/main/resources as the resource root but probably target/classes (if maven)
so i don't know if putting things into src/main/resources (i.e. the resource root at build time) will ever work
unless of course if you specify the absolute OS path to src/main/resources then it will work
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
What I came to know is in the resources folder we can only read but to write or add any file we can use the absolute path for OutputStream and write the file in that folder... thanks I got my answers @long quartz