Last active
February 20, 2016 10:36
-
-
Save umuturan/fd1cea3175d56d9da3ba to your computer and use it in GitHub Desktop.
Lab02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ArrayList<String> getLinks() { | |
ArrayList<String> list; | |
ArrayList<Integer> listInt; | |
ArrayList<Integer> listLast; | |
String addList; | |
boolean check; | |
addList = ""; | |
list = new ArrayList<String>(); | |
listInt = new ArrayList<Integer>(); | |
listLast = new ArrayList<Integer>(); | |
check = true; | |
for (int i = 0; i < getUnfilteredPageContents().length() - 3; i++) { | |
if (getUnfilteredPageContents().charAt(i) == 'h' && getUnfilteredPageContents().charAt(i + 1) == 'r' | |
&& getUnfilteredPageContents().charAt(i + 3) == 'f') { | |
listInt.add(i + 3); // the index of f at "href" | |
} | |
} | |
for (int i = 0; i < listInt.size(); i++) { | |
check = true; | |
for (int j = listInt.get(i) + 2; j < getUnfilteredPageContents().length() && check; j++) { | |
if (getUnfilteredPageContents().charAt(j) == '>') { | |
listLast.add(j); | |
check = false; | |
} | |
} | |
} | |
for(int i = 0 ; i<listInt.size(); i++){ | |
list.add(getUnfilteredPageContents().substring(listInt.get(i)+3,listLast.get(i)-1)); | |
} | |
return list; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment