I'm reading lines from a zipped input stream, and I need to filter it by the first 4 positions (a period). Is is possible to use a lambda (like the filter in streams) to avoid the condition?
private List<String> readlinesByPeriod(DPeriod period, ZipInputStream zis) throws IOException {
List<String> lines = new ArrayList();
byte[] data = SCIOUtils.readData(zis);
InputStream is = new ByteArrayInputStream(data);
BufferedReader reader = new BufferedReader(new InputStreamReader(is, CharEncoding.ISO_8859_1));
String line;
while ((line = reader.readLine()) != null) {
String periodCode = StringUtils.substring(line, 0, 4);
if (periodCode.equals(period.getCode())) {
lines.add(line);
}
}
return lines;
}