permaculture playing cards
The moose likes Java in General and the fly likes split by pipe in a string Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "split by pipe in a string" Watch "split by pipe in a string" New topic

split by pipe in a string

Isaac Ferguson
Ranch Hand

Joined: Jun 22, 2012
Posts: 595

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

I am using the next code

In my file I have


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

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

Any idea please?


Winston Gutkowski

Joined: Mar 17, 2011
Posts: 8661

Angus Ferguson wrote:Any idea please?



Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Matthew Brown

Joined: Apr 06, 2010
Posts: 4541

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:
subject: split by pipe in a string
It's not a secret anymore!