Here you can find the source of readContentsToArray(URL url)
public static String[] readContentsToArray(URL url) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.io.InputStreamReader; import java.io.LineNumberReader; import java.net.URL; import java.util.ArrayList; import java.util.List; public class Main { public static String[] readContentsToArray(URL url) throws IOException { List<String> lines = readContentsToList(url); return lines.toArray(new String[lines.size()]); }/* w w w . ja v a 2 s.co m*/ public static List<String> readContentsToList(URL url) throws IOException { LineNumberReader reader = new LineNumberReader(new InputStreamReader(url.openStream())); List<String> lines = new ArrayList<String>(); String line; while ((line = reader.readLine()) != null) lines.add(line); reader.close(); return lines; } }