JAVA/iBatis 2009. 7. 8. 16:07


import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;


public class CommentClean {

 /**
  * @param args
  * @throws IOException
  */
 
 public static void main(String[] args) throws IOException {
  StringBuffer sb = new StringBuffer();
  File newFile = new File( "파일절대경로");
  if (newFile.exists()) {
   FileReader fr = new FileReader(newFile);
   BufferedReader br = new BufferedReader(fr);
   String readData = br.readLine();
   while (readData != null) {
    sb.append(readData);
    readData = br.readLine();
   }
   int start = 0, end=0;
   while(true){
    start = sb.indexOf("/**");
    end = sb.indexOf("*/");
//    System.out.println("start : " + start);
//    System.out.println("end : " + end);
    if (start == -1 || end == -1 )
     break;
    sb.replace(start ,end+2,  "");
    start =0;
    end = 0;
   }
   
   System.out.println(sb.toString().replaceAll("}", "}\n").replaceAll(";", ";\n").replaceAll("\\{", "\\{\n"));
   br.close();
   fr.close();
  } else {
   System.out.println("파일이 업네여....");
  }

 }
}

posted by 나는너의힘
: