I'm trying to find http links in a web page.I am writing a code for it.I'm searching line by line but if the web page code, has more than one http link, my code finds only one link.What should I do?
This is my code;
import java.net.*;
import java.lang.*;
import java.util.regex.*;
import java.util.*;
public class Linkler2{
public static void main(
String args[]) throws IOException
{
String sayi;
int abc;
URL local = new URL("http://www.google.com.tr");
URLConnection baglanti = local.openConnection();
BufferedReader oku = new BufferedReader(new InputStreamReader(baglanti.getInputStream()));
PrintWriter dataOut = new PrintWriter(new FileWriter("abc2.txt"),true);
try
{
int deger=0;
int kelime=0;
while ((sayi = oku.readLine()) != null)
{
System.out.println(sayi);
kelime= sayi.indexOf("http://");
System.out.println(kelime);
if (kelime!=-1)
{
deger=deger+1;
}
dataOut.println(sayi);
}
System.out.println(deger);
}