0

I am tiring to access file from resource folder in my controller class but not able to traverse path is there any way witch I can access that fie easily or how can I traverse to paths.

The file with i want to use in my controller

The file with i want to use my controller

Code in controller class

String nodeFilePath = "D:/CodeFactory/TestCases/JavaScript/YamlToJson.js";      
ProcessBuilder pb = new ProcessBuilder("node", nodeFilePath);
pb.redirectErrorStream(true);

nodeFilePath what i want to replace with the file path in resources

Aniket Thorat
  • 107
  • 2
  • 10

1 Answers1

1

Just use ResourceLoader

then use it like this

 @Autowired
 private ResourceLoader resourceLoader;

 Resource resource = resourceLoader.getResource("classpath:YamlToJson.js");

here detail of what Resource can extract for you https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/core/io/Resource.html

DarkVision
  • 1,373
  • 3
  • 20
  • 33