Hey Guys, please I need help badly. Thank You
I read a text file from my hard disk which contains as follows....
void main()
{
int A = 5;
int B = 5;
int C ;
C = A + B;
cout << C ;
}
So, what I need to do is that..
Lets say I have an array of...
String []KeyWord = {"void", "main()"};
String []DataType = {"int", "float"};
So I want to loop through each token and check whether for example its a key word or a datatype. I used java netBeans and I code as follows
int k = 0; int l = 0;
StringTokenizer Tokens;
while ((CurrentLine = ReadFile.readLine()) != null)
{
Tokens = new StringTokenizer(CurrentLine, " ", true);
for (int i = 0; Tokens.hasMoreTokens(); i++)
{
if (Tokens.nextToken().contains(KeyWord[k]))
{
jTextArea1.append(KeyWord[k] + "\n");
k++;
}
else if (Tokens.nextToken().contains(DataType[l]))
{
jTextArea2.append(DataType[l] + "\n");
}
}
}
I RECEIVE ERRORS I DON'T UNDERSTAND. PLEASE HELP ME GUYS THANKS...