|
@@ -39,20 +39,20 @@ public class GenCodeController {
|
|
|
// File file = ResourceUtils.getFile("classpath:genjson");
|
|
// File file = ResourceUtils.getFile("classpath:genjson");
|
|
|
File file = new File(genJsonPath);
|
|
File file = new File(genJsonPath);
|
|
|
File[] fs = file.listFiles(); //遍历path下的文件和目录,放在File数组中
|
|
File[] fs = file.listFiles(); //遍历path下的文件和目录,放在File数组中
|
|
|
- for (File f : fs) { //遍历File[]数组
|
|
|
|
|
- if (!f.isDirectory()) {//若非目录(即文件),则打印
|
|
|
|
|
- System.out.println(f);
|
|
|
|
|
- reader = new BufferedReader(new FileReader(f));
|
|
|
|
|
- Gson gson = new GsonBuilder().create();
|
|
|
|
|
-
|
|
|
|
|
- GenCode genCode = gson.fromJson(reader, GenCode.class);
|
|
|
|
|
- genCodeList.add(genCode);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ if (fs != null) {
|
|
|
|
|
+ for (File f : fs) { //遍历File[]数组
|
|
|
|
|
+ if (!f.isDirectory()) {//若非目录(即文件),则打印
|
|
|
|
|
+ System.out.println(f);
|
|
|
|
|
+ reader = new BufferedReader(new FileReader(f));
|
|
|
|
|
+ Gson gson = new GsonBuilder().create();
|
|
|
|
|
+
|
|
|
|
|
+ GenCode genCode = gson.fromJson(reader, GenCode.class);
|
|
|
|
|
+ genCodeList.add(genCode);
|
|
|
|
|
+ reader.close();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- reader.close();
|
|
|
|
|
-
|
|
|
|
|
return genCodeList;
|
|
return genCodeList;
|
|
|
}
|
|
}
|
|
|
|
|
|