How to split string in java
<p>I have the below data in string format.</p>

<pre><code>String value="/SOKS/
/SREF/12345-1
/PREF/23456-1
/CREF/123"
</code></pre>

<p>Expected values:</p>

<pre><code>SOKS     setEvent("SOKS")
SREF  setRef("12345-1")
PREF  setRef1("23456-1")
CREF      setRef2("123")
</code></pre>

<h1>2:</h1>

<pre><code>String value="/SOKS/
    /SREF/
    /PREF/23456-1
    /CREF/
</code></pre>

<p>Expected values:</p>

<pre><code>SOKS1    setEvent("SOKS1")
SREF     setRef("")
PREF     setRef1("23456-1")
CREF     setRef2("")
</code></pre>

<h1>3:</h1>

<pre><code>String value="/SOKS2/
    /SREF/
    /PREF/23456-1
</code></pre>

<p>Expected values:</p>

<pre><code>SOKS2     setEvent("SOKS2")
SREF      setRef("")
PREF      setRef1("23456-1")
CREF      setRef2("")
</code></pre>

<p>I want to split the above string and set all values into a POJO.In above string /SOKS/ is dynamic, the value can be anything .</p>

<p>So I want to set this <code>value(SOKS)</code> in <code>setEvent(string)</code> method. For <code>/SREF/</code>(this is static) ,I want to store value 12345-1 into <code>setSref(string)</code>.</p>

<p>How to solve this issue?</p>
