任务:读取本地java项目src文件夹下的所有.java文件,将内容合并到doc文件中
工具:可用org.apache.poi包HWPFDocument
public static void main(String[] args) throws IOException {
// 被读取java文件总目录
String java_path = "D:\\ntwxmngsys-vue\\src";
// doc 文件目录
String doc_path = "D:\\test.doc";
// 获取所有java文件
List<File> fileList = new ArrayList<>();
File file_d = new File(java_path);
file(file_d,fileList);
// 创建doc对象
File file = new File(doc_path);
InputStream input = new FileInputStream(file);
HWPFDocument wordDocument = new HWPFDocument(input);
FileOutputStream out = new FileOutputStream(file);
Range range = wordDocument.getRange();
// 获得java输入流 写入文件
for (File file_temp : fileList){
FileInputStream fi = new FileInputStream(file_temp);
BufferedReader bi = new Bu