String (@NotNull List<String> stdoutLines, int pid) { boolean pidEncountered = false; for (String line : stdoutLines) { if (line.startsWith("p")) { int p = StringUtil.parseInt(line.substring(1), -1); pidEncountered |= p == pid; } else if (pidEncountered && line.startsWith("n")) { return line.substring(1); } } return null; }