aspose file tools*
The moose likes Beginning Java and the fly likes String Operations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String Operations" Watch "String Operations" New topic
Author

String Operations

ssasi kumar
Greenhorn

Joined: Feb 23, 2011
Posts: 26

Hi Everybody,


i have doubt from string operations. that is normally we can split string using some key words such as stringtokenizer and split functions. But now i want spliting string using general string concepts insteadof stringtokenizer and split keywords.



with regards,
sasikumar


thanks to advane
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to CodeRanch!

I'm not quite sure what you might mean by "general string concepts", but perhaps you're thinking of regular expressions? Have a look at the java.util.regex.Pattern class to see if that will meet your needs.


[Jess in Action][AskingGoodQuestions]
ssasi kumar
Greenhorn

Joined: Feb 23, 2011
Posts: 26

hi guys,
ok i will check java.regex package. but generally using java.regex package concept are understanding java experts only. so if you dont mind how do working normal string concepts using perform to stringtokenizer functions .
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

ssasi kumar wrote: normal string concepts.


Again, I have no idea what you mean by this. Maybe an example would help me?
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

why not use toArray() ... if regex is not what you are looking for


http://plainoldjavaobject.blogspot.in
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

Because String does not have a toArray() method perhaps?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

Rob Spoor wrote:Because String does not have a toArray() method perhaps?


what about ... toCharArray() ...

i was just trying to put the logic up not the exact method name ...

anyways thanks Rob ...

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

toCharArray() should only be used if you really need a char[], because it creates a new char[]. If you only need to access characters from the String you should use length() and charAt(int) instead.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11475
    
  16

prem pillai wrote:Have a look at string functions like substring(..) , indexOf(..) , lastIndexOf(..) , charAt(..) etc.

For example , the below code will print 1.


What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

fred rosenberger wrote:
What about this is unclear? What would you expect this to print? Why do you think this is wrong? We can't help you if you don't explain what you think the problem is.


I am clear about what I have pasted in this thread .... but looks like you are not at all clear about "who is asking for help ?" & "what is he asking for ?"

The person who initiated this thread is asking for various ways to split a string without using Stringtokenizer or split() method etc

Anyways thanks for asking me so many questions

Peace
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39791
    
  28
ssasi kumar wrote: . . . split string using some key words such as stringtokenizer and split functions. . . .
Careful. Those aren't keywords.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: String Operations