public static List<String> readAllLinesAsList(InputStream stream, int maxLines) throws IOException { final List<String> result = new ArrayList<String>(); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { result.add(line); } return true; } }, maxLines); return result; }
public static List<String> readAllLinesAsList(InputStream stream, int maxLines) throws IOException { final List<String> result = new ArrayList<String>(); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { result.add(line); } return true; } }, maxLines); return result; }
public static String readAllLines(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new LineHandler() { @Override public boolean handle(String line) { result.append(line); result.append('\n'); return true; } }, maxLines); return result.toString(); }
public static String readAllLinesAndIgnoreComments(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { result.append(line); result.append('\n'); } return true; } }, maxLines); return result.toString(); }
public static String readAllLinesAndIgnoreComments(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { result.append(line); result.append('\n'); } return true; } }, maxLines); return result.toString(); }
public static String readAllLines(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new LineHandler() { @Override public boolean handle(String line) { result.append(line); result.append('\n'); return true; } }, maxLines); return result.toString(); }
public static String readAllLinesAndRemoveHeader(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new SkipHeaderLineHandler() { @Override public boolean handle(String line) { if (!isHeaderLine(line)) { result.append(line); result.append('\n'); } return true; } }, maxLines); return result.toString(); }
public static Map<String, String> readAllLinesAsMap(InputStream stream, int maxLines) throws IOException { final Map<String, String> result = new HashMap<String, String>(); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { int x = line.indexOf('='); if (x < 0) { result.put(line.trim(), ""); } else { result.put(line.substring(0, x).trim(), line.substring(x + 1).trim()); } } return true; } }, maxLines); return result; }
public static Map<String, String> readAllLinesAsMap(InputStream stream, int maxLines) throws IOException { final Map<String, String> result = new HashMap<String, String>(); readLinesFromStream(stream, new IgnoreCommentsLineHandler() { @Override public boolean handle(String line) { if (!isComment(line)) { int x = line.indexOf('='); if (x < 0) { result.put(line.trim(), ""); } else { result.put(line.substring(0, x).trim(), line.substring(x + 1).trim()); } } return true; } }, maxLines); return result; }
public static String readAllLinesAndRemoveHeader(InputStream stream, int maxLines) throws IOException { final StringBuilder result = new StringBuilder(1024); readLinesFromStream(stream, new SkipHeaderLineHandler() { @Override public boolean handle(String line) { if (!isHeaderLine(line)) { result.append(line); result.append('\n'); } return true; } }, maxLines); return result.toString(); }
/** * Reads the first line from a stream and closes the stream. * * @param stream * the input stream */ public static String readFirstLine(InputStream stream) throws IOException { final StringBuilder result = new StringBuilder(128); readLinesFromStream(stream, new LineHandler() { @Override public boolean handle(String line) { result.append(line); return false; } }, 1); return result.toString(); }
/** * Reads the first line from a stream and closes the stream. * * @param stream * the input stream */ public static String readFirstLine(InputStream stream) throws IOException { final StringBuilder result = new StringBuilder(128); readLinesFromStream(stream, new LineHandler() { @Override public boolean handle(String line) { result.append(line); return false; } }, 1); return result.toString(); }