static List findImports(String src) { List imports = new ArrayList(); Pattern pattern = Pattern.compile("^\\s*import\\s+(.*?)\\s*;"); for (String line : toLines(src)) { Matcher matcher = pattern.matcher(line); if (matcher.find()) imports.add(matcher.group(1)); } return imports; }