StringBuffer Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • johnny luiz

    StringBuffer Question

    Hi All

    I just want to know if someone can help me to empty
    the values in a SringBuffer

    Thanks
    Johnny


  • IS

    #2
    Re: StringBuffer Question

    Have you considered using delete(0, int end) ?

    IS

    "johnny luiz" <johnnyl@nupay. co.za> wrote in message
    news:8amdnUtDLf [email protected].. .[color=blue]
    > Hi All
    >
    > I just want to know if someone can help me to empty
    > the values in a SringBuffer
    >
    > Thanks
    > Johnny
    >
    >[/color]


    Comment

    • Stewart Gordon

      #3
      Re: StringBuffer Question



      While it was 14/11/03 1:35 pm throughout the UK, johnny luiz sprinkled
      little black dots on a white screen, and they fell thus:
      [color=blue]
      > Hi All
      >
      > I just want to know if someone can help me to empty
      > the values in a SringBuffer[/color]

      What values?

      To empty a StringBuffer, use setLength(0) on it.

      Or do you mean something else?

      Stewart.

      --
      My e-mail is valid but not my primary mailbox, aside from its being the
      unfortunate victim of intensive mail-bombing at the moment. Please keep
      replies on the 'group where everyone may benefit.

      Comment

      • johnny luiz

        #4
        Re: StringBuffer Question

        I would like to know
        how to empty out a strring buffer.

        i am developing an application that uses serial com communication
        that receives infor from the port. i write the data into a stringbuffer.
        when new info is received at the port i read it into the stringbuffer
        but the previous data is still in the stringbuffer. ia don't what the
        previous info
        there.

        I have tried both the above mentioned scenarios adn they didnt
        help

        "Stewart Gordon" <smjg_1998@yaho o.com> wrote in message
        news:bp311u$rnu [email protected] ...[color=blue]
        >
        >
        > While it was 14/11/03 1:35 pm throughout the UK, johnny luiz sprinkled
        > little black dots on a white screen, and they fell thus:
        >[color=green]
        > > Hi All
        > >
        > > I just want to know if someone can help me to empty
        > > the values in a SringBuffer[/color]
        >
        > What values?
        >
        > To empty a StringBuffer, use setLength(0) on it.
        >
        > Or do you mean something else?
        >
        > Stewart.
        >
        > --
        > My e-mail is valid but not my primary mailbox, aside from its being the
        > unfortunate victim of intensive mail-bombing at the moment. Please keep
        > replies on the 'group where everyone may benefit.[/color]


        Comment

        • Anthony Borla

          #5
          Re: StringBuffer Question


          "johnny luiz" <johnnyl@nupay. co.za> wrote in message
          news:e4qdnXV5_N [email protected].. .[color=blue]
          > I would like to know
          > how to empty out a strring buffer.
          >
          > i am developing an application that uses serial com
          > communication that receives infor from the port. i
          > write the data into a stringbuffer.
          >
          > when new info is received at the port i read it into
          > the stringbuffer but the previous data is still in the
          > stringbuffer. ia don't what the previous info there.
          >
          > I have tried both the above mentioned scenarios adn
          > they didnt help
          >[/color]

          StringBuffer sb("ABCDE");

          // 1) Empty buffer using 'delete'
          sb.delete(0, sb.length());

          // or:

          // 2) Empty buffer using 'replace'
          sb.replace(0, sb.length(), "");

          // or:

          // 3) Empty buffer using 'setLength'
          sb.setLength(0) ;

          All three of these approaches have the effect of 'emptying' the StringBuffer
          object of its contents [of characters] but do not alter its capacity, the
          currently-available storage for additional characters.

          Your problem is likely to have other causes. Perhaps if you posted the
          relevant piece of source code constructive suggestions could be made.

          I hope this helps.

          Anthony Borla



          Comment

          Working...