Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Q] Java syntax to append a "EOF" to the end of a string?

1,917 views
Skip to first unread message

Stephen Chan

unread,
Jan 14, 1998, 3:00:00 AM1/14/98
to

Hello:

Does anyone know what's the Java syntax to append
a "EOF" character to the end of a string?

String mystring;
mystring = mystring + ?????;

Thanks
Stephen

Tov Are

unread,
Jan 14, 1998, 3:00:00 AM1/14/98
to

Try String.length(). You don't need a eof character in Java (although they
probably have zero termination internally).
Stephen Chan wrote in message
<01bd20ff$072115c0$1bf9...@direct.ca.direct.ca>...
[cut]


Roedy Green

unread,
Jan 15, 1998, 3:00:00 AM1/15/98
to

Tov Are wrote:
>although they probably have zero termination internally).

Have a look at the source code for String. Strings are actually substrings
of char[] consisting of an offset and length. Several String constants can
share a common base char[].

Unlike C/C++, Java keeps track of how long its strings are rather than
scanning for a terminating null.

For the JAVA GLOSSARY and the CMP Utilities: http://oberon.ark.com/~roedy
--
Roedy Green Roedy rhymes with Cody ro...@bix.com ICQ:5144242
Canadian Mind Products contract programming (250) 285-2954
POB 707 Quathiaski Cove Quadra Island BC Canada V0P 1N0
-30-

Daniel Barclay

unread,
Jan 16, 1998, 3:00:00 AM1/16/98
to

Stephen Chan wrote:
> ...

> Does anyone know what's the Java syntax to append
> a "EOF" character to the end of a string?

What end-of-file character?


Daniel

Roedy Green

unread,
Jan 17, 1998, 3:00:00 AM1/17/98
to

Daniel Barclay wrote:
>> Does anyone know what's the Java syntax to append
>> a "EOF" character to the end of a string?

if you mean chr$(26) you could do it with octal notation:

String s = "abc" + "\032";

if you mean chr$(0), you don't need it for Java since it tracks it own
string lengths. If you want a trailing null for native C, you could use
the same technique:

String s = "abc\000";

Daniel Barclay

unread,
Jan 20, 1998, 3:00:00 AM1/20/98
to

Roedy Green wrote:
>
> Daniel Barclay wrote:
> >> Does anyone know what's the Java syntax to append
> >> a "EOF" character to the end of a string?
>
> ...

Hey. Don't quote me out of context.

I didn't ask that question; your message could imply that I did.

Daniel

0 new messages