if ((line = br.readLine()).contains("PID")){ TestResultDTO t = new TestResultDTO(); t.pid = line.substring(beginIndex); t.list = new ArrayList<String>(); while ((line = br.readLine()) != "-------") { t.list.add(line)} }