-
boolean to string
I'm reading lines from a file and one of the value is boolean.
Code:
while ((aRecord=ins.readLine())!= null)
{
strings = new StringTokenizer(aRecord,"?"); //toekenizer
if (strings.countTokens() == 3) {
accountName = strings.nextToken();
accountPhone = strings.nextToken();
accountStatus = strings.nextToken(); //this is boolean
}
accountStatus is boolean causes an error. I have tried this:
Code:
accountStatus = strings.nextToken();
still doesn't seem to work.
-
Code:
accountStatus = new Boolean(strings.nextToken()).booleanValue();
You can omit .booleanValue for Java 1.5+ because of autoboxing ..
-
great. that works perfectly.