StringBuffer Problem

Hey guys. I have a program in which I get user input through a GUI, parse that input to a StringBuffer, then pass the StringBuffer over to another file, which then uses the input to run a program. I want the program to be run only if the user actually does put input in.

I thought I could do this with a simple if statement, such as:

if (FPTMchoicesBuffer !=null){

...

}

But this isn't working, the program just runs no matter what. Is there any other way for me to test if the StringBuffer was written to?

[664 byte] By [rtharak1a] at [2007-10-3 2:18:03]
# 1
Like FPTMchoicesBuffer.toString().length != 0Also, user StringBuilder instead of StringBuffer
zadoka at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...
# 2
yes, if you have just initialize your StringBuffer (ed: StringBuffer mybuffer = new StringBuffer() ) it is not null !!Check the StringBuffer length or content with regExp.
UBERTI84a at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...
# 3
if (FPTMchoicesBuffer.length() > 0) {... }
kajbja at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...
# 4
Thanks guys, it worked.Zadok, I read that I should use StringBuffer instead. Something about synchronization. Should I not?
rtharak1a at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...
# 5

> Thanks guys, it worked.

>

> Zadok, I read that I should use StringBuffer instead.

> Something about synchronization. Should I not?

Is the StringBuffer used by multiply threads?

Yes, use StringBuffer

No, Use StringBuilder, it is slightly faster.

mlka at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...
# 6
> Thanks guys, it worked.> > Zadok, I read that I should use StringBuffer instead.> Something about synchronization. Should I not?See reply #5 by mlk.(I was assuming you weren't using threads, but I should have asked)
zadoka at 2007-7-14 19:16:56 > top of Java-index,Java Essentials,New To Java...