Hi... I am trying to find a curly brace out of a input file. The code is as following. But i get no output.My purpose is to find find the curly brace and load it inside an array and find the corresponding curly brace so that i can find cyclometic complexity within a method. please help me...
is there any other easier way of finding the position of method so that i can just get the codings within a method....
public String methodfromtokens()
{
String output = "", line = "";
try {
br = new BufferedReader (new FileReader(file));
while ((line = br.readLine()) != null)
{
StringTokenizer words =new StringTokenizer(line);
numtoken = words.countTokens();
String load[] = new String [numtoken];
int conubt = 0;
int j;
while (words.hasMoreTokens())
for( j=0; j<numtoken; j++)
{
load[j]= words.nextToken();
}
for ( j=0; j<numtoken; j++)
{
Pattern p = Pattern.compil("{");
Matcher m = p.matcher(load[j]);
found = m.find();
if (found == true)
{
System.out.println( "The braces found is " +m.group()+ "\n");
brace++;
}
System.out.println( "The number of braces is " +brace+ "\n");
}
}
System.out.println("Number of words : " + numtokens);
} catch (IOException e){}
return null;
}
is there any other easier way of finding the position of method so that i can just get the codings within a method....
public String methodfromtokens()
{
String output = "", line = "";
try {
br = new BufferedReader (new FileReader(file));
while ((line = br.readLine()) != null)
{
StringTokenizer words =new StringTokenizer(line);
numtoken = words.countTokens();
String load[] = new String [numtoken];
int conubt = 0;
int j;
while (words.hasMoreTokens())
for( j=0; j<numtoken; j++)
{
load[j]= words.nextToken();
}
for ( j=0; j<numtoken; j++)
{
Pattern p = Pattern.compil("{");
Matcher m = p.matcher(load[j]);
found = m.find();
if (found == true)
{
System.out.println( "The braces found is " +m.group()+ "\n");
brace++;
}
System.out.println( "The number of braces is " +brace+ "\n");
}
}
System.out.println("Number of words : " + numtokens);
} catch (IOException e){}
return null;
}