The below example shows you how to write contents of java file to a text file.
Step 1: Open cmd.exe
Step 2: First go to the folder which contains the class file of the java file
Step 3: Execute the line javap filename >test.txt
where filename is the name of the class file.(Do not enter extension)
Now you will see a text file created in the folder with the given file name;