title: String newline split from file
body: <p><strong>a.txt :</strong></p>
  
  <pre><code>1,2,3
  1,2,6
  2,4,5
  </code></pre>
  
  <p><strong>Reading and splitting</strong></p>
  
  <pre><code>String wynik = readFileAsString("a.txt");
  String[] wyniki = wynik.split("");
  </code></pre>
  
  <p>I can't seem to find a way to split String out after newLines that are in file, and not specified like this (this is what I found on all other examples on stackoverflow):</p>
  
  <pre><code>1,2,3\n1,2,6\n2,4,5\n
  </code></pre>
  
  <p>My readFileAsString works correctly, and it actually reads it that way (without splitting):</p>
  
  <pre><code>1,2,31,2,62,4,5
  </code></pre>
  
  <p>I know I could add something to my file, to make it split by it, eg</p>
  
  <pre><code>1,2,3t
  ...
  </code></pre>
  
  <p>But I also need that file to be clear and without any unnecessary symbols.</p>
  
  <p>Entire thing looks like this:</p>
  
  <pre><code>public static String readFileAsString(String file) {
      String line, results = "";
      try {
          BufferedReader reader = new BufferedReader(new FileReader(file));
          // readLine() zwraca nulla na koncu pliku, stad zabezpieczenie
          while ((line = reader.readLine()) != null) {
              results += line;
          }
          reader.close();
          // return results;
      } catch (IOException e) {
          System.err.println("Error");
      }
      return results;
  }
  
      public static void main(String args[]) {
  
          String wynik = readFileAsString("a.txt");
          System.out.println(wynik);
          String[] wyniki = wynik.split("[\\r\\n]+");
  
          ArrayList&lt;Trojka&gt; wynikArrList = new ArrayList&lt;Trojka&gt;();
  
          for (int i = 0; i &lt; wyniki.length; i++) {
              String[] temp1 = wyniki[i].split(",");
              int m = 0;
              int n = 0;
              int t = 0;
              try {
                  m = Integer.parseInt(temp1[0]);
              } catch (Exception e) {
              }
              try {
                  n = Integer.parseInt(temp1[1]);
              } catch (Exception e) {
              }
              try {
                  t = Integer.parseInt(temp1[2]);
              } catch (Exception e) {
              }
  
              Trojka temp = new Trojka(m, n, t);
  
              boolean newRecord = true;
              for (Trojka a : wynikArrList) {
                  if (a.getM() == temp.getM() &amp;&amp; a.getN() == temp.getN()) {
                      a.addT((int) temp.getT());
                      newRecord = false;
                      break;
                  }
              }
              if (newRecord) {
                  wynikArrList.add(temp);
              }
          }
  
          wynik = "";
  
          for (Trojka a : wynikArrList) {
              wynik += a.getM() + "," + a.getN() + "," + a.getT() + "\n";
          }
  
          System.out.println(wynik);  
  
      }
  }
  </code></pre>