Here you can find the source of readFileWithoutComments(File input)
public static Set<String> readFileWithoutComments(File input) throws FileNotFoundException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileNotFoundException; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class Main { public static Set<String> readFileWithoutComments(File input) throws FileNotFoundException { Set<String> adsList; try (Scanner scanner = new Scanner(input)) { adsList = new HashSet<String>(10000); final String COMMENT_MARKER = "#"; while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); if (line.startsWith(COMMENT_MARKER) || line.isEmpty()) { continue; }/*from ww w. j av a2s . co m*/ line = line.replaceAll(COMMENT_MARKER + ".*$", ""); adsList.add(line); } } return adsList; } }