Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void findURLs(File file) {
- try {
- BufferedReader br = new BufferedReader(new FileReader(file));
- String line = "";
- Pattern pattern = Pattern.compile("(?i)href=\".+\"");
- while ((line = br.readLine()) != null) {
- Matcher m = pattern.matcher(line);
- while (m.find()) {
- String[] urls = m.group().split("(?i)\\s+");
- for (String s : urls) {
- if (s.matches("(?i)href=\".+\"")) {
- String[] cleaned = s.split("(?i)href=");
- for (String str : cleaned) {
- if (!str.isEmpty())
- System.out.println(str.substring(1, str.length()-1));
- }
- }
- }
- }
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment