Our nine-day bird-to-peer network loan system is basically a development completed.
Now, you want to add the copyright information to the backend Java code.
Manual go to Copy-paste, too no technical content.
So, wrote a Java tool class, to add copyright information to the Java source file.
The source code, the beginning of the comment, is the copyright description. Detailed implementation, just look at the code bar.
/* *copyright ? 2015 jiutianniao * Wuhan nine days Bird Technology Co., Ltd. *http://jiutianniao.com *All rights reserved. */package com.jiutianniao.p2p.base.util;import java.io.bufferedreader;import java.io.file;import java.io.filereader;import java.io.filewriter; import org.apache.log4j.logger;//to Java files, add copyright information public class copyrightutil {private Static logger log = logger.getlogger (copyrightutil.class);p ublic static void main (String[] args) throws exception {//java file directory string dir = "E:/ Gitrepository/funds "; File file = new file (dir); addcopyright4directory (file);} Public static void addcopyright4directory (File file) throws exception {file [] files = file.listfiles ();if (files == null | | files.length == 0) {return;} for (FILE F :&NBsp;files) {if (F.isfile ()) {addcopyright4file (f); System.out.println ("file = = =" + f.getname ());} else {system.out.println ("directory = =" + f.getname ()); Addcopyright4directory (f);}} Public static void addcopyright4file (File file) throws exception {string filename = file.getname (); Boolean isjava = filename.endswith (". Java");if ( !isjava) {log.info ("This file is not java source file,filaname=" + filename); return;} if (Isjava) {// Copyright string string copyright = "/*\n *copyright ? 2015 JiuTianNiao\n "+ " * Wuhan nine Days Bird Technology Co., Ltd. \n " + " *http://jiutianniao.com\n "+ " * All rights reserved.\n */\n "; //tried to use the Randomaccessfile.writeutf, the problem is that the opening character is "NUL", not solved. Bufferedreader br = new bufferedReader (New filereader (file)); string line; string content = "";//Read a line, be sure to add "line break", Windows can be directly used "\ n" string lineseperator = "\ n";// Lineseperator = system.getproperty ("Line.separator") while ((Line = br.readline ()) != null) {content += line + lineseperator;} Br.close (); //write the string back to the stitching filewriter filewriter = new filewriter (file); Filewriter.write (copyright); filewriter.write (content); Filewriter.close ();}}
Wuhan nine days bird-p2p network Loan system development-Internet application software development
Company official website: http://jiutianniao.com
Social quiz: http://ask.jiutianniao.com
Java Tools class: Add copyright information to Programs