Skip to content

Instantly share code, notes, and snippets.

@scola
Created March 26, 2018 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scola/6cb68ef9d0645c332a43f5ee14e02529 to your computer and use it in GitHub Desktop.
Save scola/6cb68ef9d0645c332a43f5ee14e02529 to your computer and use it in GitHub Desktop.
get all java code to generate one txt
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