Skip to content

Instantly share code, notes, and snippets.

@darrinholst
Created May 18, 2009 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrinholst/113588 to your computer and use it in GitHub Desktop.
Save darrinholst/113588 to your computer and use it in GitHub Desktop.
private void parseWebPage() {
String line = "";
String url = "";
String proto[] = { "http://", "https://" };
try {
RandomAccessFile f = new RandomAccessFile(getAction(), "r");
while ((line = f.readLine()) != null) {
for (int protocounter = 0; protocounter < proto.length; protocounter++)
if (line.contains(proto[protocounter])) {
try {
url = line.substring(line.indexOf(proto[protocounter]), line.indexOf(" ", line.indexOf(proto[protocounter]) + 1));
}
catch (Exception e2) {
url = line.substring(line.indexOf(proto[protocounter]));
}
try {
webpage = url.substring(url.lastIndexOf("/") + 1, url.indexOf("?", url.lastIndexOf("/") + 1));
}
catch (Exception e3) {
try {
webpage = url.substring(url.lastIndexOf("/") + 1, url.indexOf(" ", url.lastIndexOf("/") + 1));
}
catch (Exception e4) {
try {
webpage = url.substring(url.lastIndexOf("/") + 1);
}
catch (Exception e5) {
webpage = "ERROR";
}
}
}
}
}
if (webpage.charAt(webpage.length() - 1) == '"')
webpage = webpage.substring(0, webpage.length() - 1);
}
catch (Exception e) {
webpage = "ERROR";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment