Results 1 to 3 of 3
  1. #1
    otoro_java is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

    Default boolean to string

    I'm reading lines from a file and one of the value is boolean.

    Java 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:
    Java Code:
     accountStatus = strings.nextToken();
    still doesn't seem to work.

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    Java Code:
     accountStatus  = new Boolean(strings.nextToken()).booleanValue();
    You can omit .booleanValue for Java 1.5+ because of autoboxing ..
    dont worry newbie, we got you covered.

  3. #3
    otoro_java is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

Similar Threads

  1. Replies: 6
    Last Post: 10-08-2008, 08:09 AM
  2. Replies: 4
    Last Post: 04-15-2008, 01:04 PM
  3. boolean variables
    By ravian in forum New To Java
    Replies: 3
    Last Post: 12-31-2007, 04:58 AM
  4. Replies: 0
    Last Post: 11-20-2007, 04:59 PM
  5. Boolean Expression
    By ritwik07 in forum New To Java
    Replies: 3
    Last Post: 07-11-2007, 04:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •