The Artima Developer Community
Sponsored Link

Java Answers Forum
Help me about String

3 replies on 1 page. Most recent reply: Oct 18, 2005 6:42 PM by boysoledad

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
boysoledad

Posts: 7
Nickname: lunar
Registered: Aug, 2005

Help me about String Posted: Aug 27, 2005 2:32 AM
Reply to this message Reply
Advertisement
i have a string = "This is a text"
I want write java println
This
is
a
text

and i want get int of Character BackSpace
4 7 9

Please help me about code show it....


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Help me about String Posted: Aug 28, 2005 11:31 PM
Reply to this message Reply
Use the replace method to replace " " with "\n".

String s = "This is a Text";

System.out.println (s.replaceAll(" ", "\n"));

Don't understand your question about Backspace. There is no BackSpace in your example. There are just "Space" characters.
The ASCII code is 32.

But if you want to get the unicode int wich java uses, then use Character.getNumericValue();

Subodh Rawat

Posts: 9
Nickname: zeon
Registered: May, 2005

Re: Help me about String Posted: Sep 30, 2005 4:42 PM
Reply to this message Reply
Hi Lunar,

Use the StringTokenizer class

StringTokenizer strToken = new StringTokenizer("This is a Text");
String strTemp = null;
while (strToken.hasMoreTokens())
{
strTemp = strToken.nextToken();
System.out.print("String is : " + strTemp);
System.out.println("\tSize : " + strTemp.length());

}

For more details on the StringTokenizer look into the Java API for StringTokenizer class.

-Zeon

boysoledad

Posts: 7
Nickname: lunar
Registered: Aug, 2005

Re: Help me about String Posted: Oct 18, 2005 6:42 PM
Reply to this message Reply
Thankx it's work great

Flat View: This topic has 3 replies on 1 page
Topic: where i need to modify for below program ?? (java> synchronized) Previous Topic   Next Topic Topic: How to add a property listener for variable

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use