Java — How to load a file from resources folder?
Sometime during tests you may want to read a file from resources folder; and here is the java code which you can use to read the file:
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// read as input stream
InputStream is = classloader.getResourceAsStream("GameOfThronesS01E01.m3u8");
// read as a file
File file = new File(classLoader.getResource("GameOfThronesS01E01.m3u8").getFile());