Finding A URl on a Page Java Code --Java Programming: Solving Problems with Software
/**
* Write a description of URLFINDER here.
*
* @author (your name)
* @version (a version number or a date)
*/
import edu.duke.*;
import java.io.*;
public class URLFINDER
{
public void asd(){
URLResource file = new URLResource("http://www.dukelearntoprogram.com/course2/data/manylinks.html");
for ( String item : file.words() ) {
String itemLower = item.toLowerCase();
int pos = itemLower.indexOf("youtube.com");
if ( pos != -1 ) {
int beg = item.lastIndexOf("\"", pos);
int end = item.indexOf("\"", pos + 1);
System.out.println(item.substring(beg + 1, end));
}
}
}
}
Comments
Post a Comment