I have this code which load the File from class path a=its text file and i want to read it to string what im using is :
File file = new File(classLoader.getResource("sample.json").getFile());
i don't want to use:
file.getAbsolutePath();
how can i read this text file into String ?
UPDATE i found the solution , what do you think?
ClassLoader classLoader = getClass().getClassLoader();
is = classLoader.getResourceAsStream("sample.json");
String txt = IOUtils.toString(is);