Question

For my Java assignments, I usually have to copy/paste my source code into my report. Business as usual. However, for bigger projects it is kind of annoying to copy and paste a bunch of classes.

Does anyone know if Eclipse has a function that allows you to view all your classes in one file, or something like that?

If that is confusing: I want to be able to view all my classes for a given project in a single document/viewer/something without copying and pasting. Can it be done with relative ease?


EDIT: As a commenter noted, preserving syntax highlighting would be great. Solutions that can retain that feature would be nice.

Was it helpful?

Solution

I would say that the fastest way is not using Eclipse, but external tools like bash scripting. For example, in Linux's shell or Windows Cygwin terminal you can use:

find src_folder -type f  | egrep "\.java$" | 
  while read -r file_name  
do 
   cat "$file_name" >> myoutputfile.txt 
done

So what it actually does is find all the files which have the .java extension, print them and redirect and append stdout to myoutputfile.txt .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top