Consider the following classes:
public class Store {
private final ArrayList<String> store;
public ArrayList<String> getStore() {
return store;
}
public Store(ArrayList<String> store){
this.store = store;
}
}
I have a text file called input.txt
I have a normal controller which is annotated with @RestController
as follows:
@RestController
@RequestMapping(value="/test")
public class Controller {
.
.
.
}
I need to do the following operations:
- Read input.txt by using
Files.readAllLines(path,cs)
(from JDK 1.7) - Set the returned value(
List<String>
) toStore.store
- I wanna use Spring annotations all the way (I'm writing a spring-boot application)
- I need Store to be a Singleton bean.
- The store needs to be initialized during the bootstrapping of my application.
This question might be too vague, but I have absolutely no idea about how to make it more specific.
P.S.
I'm a newbie to Spring.