Java split string at “,” and end of line

I have some data that looks like this:


Now I do want to split the string at the "," and at the end of the line. I tried it like this:

String[] results = file.split(",");

This works fine, but when I try this:

String[] results = file.split(",||\\n+");

The whole thing gets messed up, I hope you can help :)


You can use a better way:

String[] results = a.split(",|"+System.getProperty("line.separator")+"+");

Because the line separator changes between OS..

Try this:

String[] results = file.split(",|\\n+");

Need Your Help

Sharing menu bar between activities

android button android-activity menu share

I have a menu bar on my app, that I need to share between 5 of my activities. My menu bar (= 5 buttons allowing to switch between activities) has exactly the same UI and the same behavior for any

Expanding a shortened url to its original full length url in java

java url urlconnection

I'm attempting to take a shortened url and expand it out to its original full length url in a string format in java. I've been able to track down a tutorial online, however I'm unable to get this to