Here you can find the source of readLinesTrimmedNoCommentFromUrl(final URL fileUrl, final String commentString)
public static String[] readLinesTrimmedNoCommentFromUrl(final URL fileUrl, final String commentString) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.util.ArrayList; public class Main { public static String[] readLinesTrimmedNoCommentFromUrl(final URL fileUrl, final String commentString) throws IOException { BufferedReader in = null; try {/*from ww w.j a v a 2 s . c o m*/ in = new BufferedReader(new InputStreamReader(fileUrl.openStream())); } catch (IOException e) { throw new IOException("IOException during reading from URL: \"" + fileUrl + "\""); } return readLinesTrimmedNoCommmentFromBufferedReader(in, commentString); } private static String[] readLinesTrimmedNoCommmentFromBufferedReader(final BufferedReader in, final String commentString) throws IOException { ArrayList<String> lineList = new ArrayList<String>(); String line; while (in.ready()) { line = in.readLine(); if (line == null) { continue; } line = line.trim(); if (line.startsWith(commentString)) continue; if (line.contains(commentString)) { String[] items = line.split(commentString); line = items[0].trim(); } lineList.add(line); } in.close(); String[] lines = new String[lineList.size()]; lineList.toArray(lines); return lines; } }