Anyframe Core

anyframe.common.util.file
Class GrepFile

java.lang.Object
  extended by anyframe.common.util.file.GrepFile

public abstract class GrepFile
extends Object

Utility class to provide a subset of the grep functionality.

Author:
SoYon Lim, JongHoon Kim

Method Summary
static boolean containsPattern(File file, Pattern pattern)
          Check if the given file name contains the pattern
static File[] find(File file, String searchString)
          Find all files below the given file which contain the given search string.
static File[] find(File file, String searchString, boolean containsDirectory)
           
static String[] findPattern(File file, Pattern pattern, int group)
          Find all occurences of pattern in a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

containsPattern

public static boolean containsPattern(File file,
                                      Pattern pattern)
                               throws IOException
Check if the given file name contains the pattern

Parameters:
file - the file which is to be searched for the pattern
pattern - the pattern that is being searched.
Returns:
true if the file contains the string, false otherwise.
Throws:
IOException

findPattern

public static String[] findPattern(File file,
                                   Pattern pattern,
                                   int group)
                            throws IOException
Find all occurences of pattern in a file.

Parameters:
file - the file to search for occurences of pattern
pattern - the pattern to search for
group - which group in the pattern to return
Returns:
an array of occurences of pattern (i.e. the groupth group of the match)
Throws:
IOException - if the file could not be read.

find

public static File[] find(File file,
                          String searchString)
                   throws IOException
Find all files below the given file which contain the given search string.

Parameters:
file - the where to start the search
searchString - the string to search for.
Returns:
an array of files which contain the search string.
Throws:
IOException - if any of the files could not be opened.

find

public static File[] find(File file,
                          String searchString,
                          boolean containsDirectory)
                   throws IOException
Throws:
IOException

Anyframe Core

Copyright © 2008-2009 Samsung SDS. All Rights Reserved.