package com.didispace.web;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.metrics.CounterService;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String index(){
try {
readFiles("classpath:vul");
} catch (Exception e) {
e.printStackTrace();
}
return "Hello World";
}
public void readFiles(String path) throws Exception{
File rootPath = ResourceUtils.getFile(path);
if(rootPath.exists()){
File[] files = rootPath.listFiles();
for (File file : files) {
if (file.isDirectory()) {
readFiles(file.getAbsolutePath());
} else {
循环遍历读取resource目录某个子目录下的文件
最新推荐文章于 2023-05-07 11:07:24 发布