상세 컨텐츠

본문 제목

tag 내용(,구분자) 20개 제한 및 /score 뺴기

IT 세상/자바세상

by 이현민 (지후지율아빠) 2010. 4. 1. 20:24

본문


 public int reduceMkeTag(String strSrcDir, String strTgtDir) throws IOException {
   String basePath = strSrcDir; // ?????? ??? ???

   String cpPath = strTgtDir; // ????? ??????? ??? ???? ???

   File fDir = new File(basePath); // ???? ????

   String[] sFiles = fDir.list(); // ???? ?????

   for (int i = 0; i < sFiles.length; i++)

   {
    try {
     FileInputStream fi = new FileInputStream(basePath
       + File.separatorChar + sFiles[i]);
     BufferedReader b = new BufferedReader(new InputStreamReader(fi,
       "utf-8"));

     if (sFiles[i].indexOf("D-C.SCD") > 0) {
      continue;
     }
     String line;
     int ii = 1;
     // ???? ????
     FileOutputStream fw = new FileOutputStream(cpPath + sFiles[i]);
     BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
       fw, "UTF-8"));
     
     while ((line = b.readLine()) != null) {
      if (line.indexOf("<TOPIC>") >= 0) {
       String strTmp=line.trim().substring(line.indexOf("<TOPIC>")+7);
       String str[] = strTmp.split(",");
       if (str.length>20){
        line="<TOPIC>";
        for (int k=0; k<21; k++){
         line+=str[k];
         if (k<20) line+=",";
        }
       }
       str=null;
      }else{
       
      }
      String strPattern="/[0-9]{1,3}[,]";
      //Pattern p = Pattern.compile(strPattern);
      line = line.replaceAll(strPattern,",");
      strPattern="/[0-9]{1,3}";
      line = line.replaceAll(strPattern,"");
      bw.write(line + newLine);
     }
     bw.close();
     fw.close();
     b.close();
     System.out.println("done:" + sFiles[i]);
    } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
   }

   return 0;
  } 

반응형

'IT 세상 > 자바세상' 카테고리의 다른 글

ant, eclipse jar 만들기  (0) 2010.05.29
jsp filedown 소스  (0) 2010.05.27
MD5  (1) 2010.03.22
mysql의 최대 성능 향상 방법  (0) 2010.03.19
dom4j 사용하기  (0) 2010.03.19

관련글 더보기