-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscratch_14.py
More file actions
17 lines (15 loc) · 908 Bytes
/
Copy pathscratch_14.py
File metadata and controls
17 lines (15 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import os
def read_java_files_to_txt(target_dir, output_file):
with open(output_file, 'w', encoding='utf-8') as output:
for root, dirs, files in os.walk(target_dir):
for file in files:
if file.endswith('.java'):
file_path = os.path.join(root, file)
relative_path = os.path.relpath(file_path, target_dir)
with open(file_path, 'r', encoding='utf-8') as java_file:
file_content = java_file.read()
output.write(f'相对路径\n{relative_path}\n文件名\n{file}\n文件内容\n{file_content}\n------------分割线------------\n')
# 使用示例
target_directory = r'T:\电影\TinkerTool' # 替换为你的Java文件所在的目录路径
output_txt_path = 'tconstruct.txt' # 输出的文本文件路径
read_java_files_to_txt(target_directory, output_txt_path)