I want to read a file and get the the number of unique words in it. So far I am able to read the file line by line (readline), store it in an arraylist and then manipulate the string.

My input will look like :

> 
> (OR (OR tv party) (study))
>  (=> exam (NOT (OR tv party)))
> 
> 
> 

Basically, I am trying to convert each line from prefix to infix and I need to find out all the diff variables involved in the input file (like tv, party etc) so that I can construct a truth table and test the cases.

Currently I am manipulating all the Strings in the array list. Is there a better way yo do this?