title: ByteArrayOutputStream to String Array
body: <p>I'm writing an application which has a method that will download a text file from my server. This text file will contain ~1,000 proxy IP's. The download will happen every 10 minutes. I need to find the most efficient way of doing this. </p>
  
  <p>Currently I have a method in a class called Connection which will return the bytes of whatever I want to retrieve. So if I make a connection to the server for the text file using such method, I will get it returned in bytes. My other method will create a very long string from these bytes. After, I split the long string into an array using System.LineSeparator. Here is the code:</p>
  
  <pre><code> public static void fetchProxies(String url) {
      Connection c = new Connection();
      List&lt;Proxy&gt; tempProxy = new ArrayList&lt;Proxy&gt;();
      ByteArrayOutputStream baos = 
              c.requestBytes(url);  
      String line = new String(baos.toByteArray()); 
  
      String[] split = line.split(System.lineSeparator());
      //more code to come but the above works fine.
  
  }
  </code></pre>
  
  <p>This currently works but I know that it isn't the most efficient way. I</p>
  
  <p><b> My Problem </b><br>
  <b>Instead of turning the bytes into a very long string, what is the most efficient way of turning the bytes into my IP's so I can add each individual IP into an arraylist and then return the arraylist full of IP's? </b></p>