• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

split by pipe in a string

 
Isaac Ferguson
Ranch Hand
Posts: 831
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I need split by "|" when I reading from a file.

I am using the next code



In my file I have

Dod1|2|3


I get the next out put "" "D""o""d""1""|".............

But I want an output like "Dod1" "2" "3"

Any idea please?

Thanks

 
Winston Gutkowski
Bartender
Pie
Posts: 9497
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angus Ferguson wrote:Any idea please?

Try
fileLine.split("[|]")

Winston
 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you want to know why your original didn't work, have a look at the docs for java.lang.String#split(java.lang.String). It doesn't treat the argument as a simple string.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic