Created
March 26, 2018 05:00
-
-
Save scola/6cb68ef9d0645c332a43f5ee14e02529 to your computer and use it in GitHub Desktop.
get all java code to generate one txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import glob | |
def getalljava(folder): | |
for file in os.listdir(folder): | |
if os.path.isdir(os.path.join(folder, file)): | |
getalljava(os.path.join(folder, file)) | |
elif file.endswith(".java") or file.endswith("java.txt"): | |
alljava.append(os.path.join(folder, file)) | |
def main(): | |
root = os.getcwd() | |
#all_project = os.listdir(root) | |
#src = [os.path.join(root, s, "src") for s in all_project if os.path.exists(os.path.join(root, s, "src"))] | |
#for java in src: | |
getalljava(root) | |
with open("alljava.txt", "w") as fw: | |
for file in alljava: | |
with open(file) as f: | |
fw.write("///// " + file) | |
fw.write("\n") | |
fw.write(f.read()) | |
fw.write("\n") | |
if __name__ == '__main__': | |
alljava = [] | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment