java - How to read a text file from spring xd module jar -


i have spring xd module, packaged jar file. want put text file in resources , read data file when module launched.

what have tried far

   thread.currentthread().getclass().getclassloader().getresource("file")    thread.currentthread().getcontextclassloader().getresource("file") 

but didn't work. how read text files module jar?

i have figured out.

you add member tasklet class

@autowire resourceloader resourceloader; 

and when need load file jar this.

inputstream stream = resourceloader.getresource("/path/inside/jar/file").getinputstream(); 

dont' forget close stream :)


Comments

Popular posts from this blog

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

matlab - error with cyclic autocorrelation function -

php - Using grpc in Laravel, "Class 'Grpc\ChannelCredentials' not found." -