Applying Python to modify Java code
1) You'll need a Python interpreter. Check this out in http://python.org.
2) You'll need to enter the root file directory of the Java project, like
python AddLicense.py ${path} where ${path} defines user project root directory.3) See http://fcmanager.wiki.sourceforge.net
1 2 1:# Python script to add the LGPL notices to each java file of the FileContentManager project. 3 2:import os, glob, sys 4 3:License = """\ 5 4:/** 6 5:*FileContentManager is a Java based file manager desktop application, 7 6:*it can show, edit and manipulate the content of the files archived inside a zip. 8 7:* 9 8:*Copyright (C) 2008 10 9:* 11 10:*Created by Camila Sanchez [http://mimix.wordpress.com/], Rafael Naufal [http://rnaufal.livejournal.com] 12 11:and Rodrigo [rdomartins@gmail.com] 13 12:* 14 13:*FileContentManager is free software; you can redistribute it and/or 15 14:*modify it under the terms of the GNU Lesser General Public 16 15:*License as published by the Free Software Foundation; either 17 16:*version 2.1 of the License, or (at your option) any later version. 18 17:* 19 18:*This library is distributed in the hope that it will be useful, 20 19:*but WITHOUT ANY WARRANTY; without even the implied warranty of 21 20:*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 21:*Lesser General Public License for more details. 23 22:* 24 23:*You should have received a copy of the GNU Lesser General Public 25 24:*License along with FileContentManager; if not, write to the Free Software 26 25:*Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ 27 26: 28 27:size = len(sys.argv) 29 28:if size == 1 or size > 2: 30 29: print "Usage: AddLicense.py $1" 31 30: sys.exit(1) 32 31:inputPath = sys.argv[1] 33 32:if not os.path.exists(inputPath): 34 33: print inputPath, "does not exist on disk" 35 34: sys.exit(1) 36 35:if not os.path.isdir(inputPath): 37 36: print inputPath, "isn't a dir" 38 37: sys.exit(1) 39 38:for path, dirs, files in os.walk(inputPath): 40 39: fileWithLicense = '' 41 40: for filepath in [ os.path.join(path, f) 42 41: for f in files if f.endswith(".java")]: 43 42: content = file(filepath).read() 44 43: f = file(filepath, "w") 45 44: print >>f, License + "\n" + content 46 45: f.close() 47 46: 48 47: