12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package com.sinosoft.cm.util;
- import java.io.BufferedReader;
- import java.io.FileInputStream;
- import java.io.InputStreamReader;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- import org.jfree.util.Log;
- public class FileUtils {
-
- public static String getClassName(String path,String regex,String joinStr){
- StringBuffer joinSB=new StringBuffer(joinStr);
- Matcher mather=null;
- Pattern pt=Pattern.compile(regex);
- StringBuffer sb=new StringBuffer();
- try {
- FileInputStream fis=new FileInputStream(path);
- InputStreamReader isr=new InputStreamReader(fis,"utf-8");
- BufferedReader br=new BufferedReader(isr);
- String str=null;
- while((str=br.readLine())!=null){
- sb.append(new StringBuffer(str));
- }
- br.close();
- isr.close();
- fis.close();
- } catch (Exception e) {
- Log.info(e.getMessage());
- }
- mather=pt.matcher(sb.toString());
- sb=new StringBuffer();
- while(mather.find()){
- String tem=mather.group().trim();
- if(!"".equals(tem)){
- sb.append(tem).append(joinSB);
- }
- }
- return sb.toString();
- }
-
-
- }
|