spring project file under way to obtain resources
Recently wrote to read template files to do some follow-up treatment, place the file in the resources under the project, found a nice reading method:
For example, the top is the file you need to read: The
way to read as follows:
//File file = ResourceUtils.getFile("classpath:templates/b_dfd.txt"); File file = ResourceUtils.getFile("classpath:templates"); if(file.exists()){ File[] files = file.listFiles(); if(files != null){ for(File childFile:files){ System.out.println(childFile.getName()); } } }
On top of ResourceUtils.getFile () method can get to files in the resources.
A few days ago found that this method is useless in linux system, I hope I have your attention.