Read a file from resources folder in Java
String fileName="build.txt"; ClassLoader classLoader = getClass().getClassLoader(); InputStream in = classLoader.getResourceAsStream(fileName); BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(in)); String buildNumberStr= bufferedReader.readLine(); bufferedReader.close(); result=buildNumberStr;
References
https://www.mkyong.com/java/java-read-a-file-from-resources-folder/