java - how to access resources(Excel file) in jar file -


hi have exported java project executable jar file. inside project accessing excel file containing data. not able access excel file when trying access file.

my project structure is:
java_project_folder
- src_folder
- resources_folder(containing excel file)

i accessing excel file

fileinputstream file=new fileinputstream(new file(system.getproperty("user.dir") +file.separator+"resources"+file.separator+"excel.xlsx")); 

i have tried accessing file using getresourceasstream like:

fileinputstream file=(fileinputstream) this.getclass().getresourceasstream ("/resources/excel.xlsx"); 

but getting in null exception. whats wrong can help?

i tried , working me.

my test1 class in default package, check accessing class in package, if go exact resource folder classpath "../"

public class test1 {      public static void main(string[] args) {         new test1();       }     test1(){         bufferedinputstream file= (bufferedinputstream) this.getclass().getresourceasstream("resources/a.txt");         try {             system.out.println((char)file.read());         } catch (ioexception e) {             // todo auto-generated catch block             e.printstacktrace();         }     }  } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -