I make the other day a question here, but finally I decided to do it myself for questions of time, now I have a little more time to fix it :D I liked jSoup, but I'm kind of from old school, and preffer doing it my self (thanks to @Bakkal anyway).
I manage to made this code, it works fine for now, but if a webpage is not well contructed it will break the code, for example if it doesn't start with http the code is not going to find it, and if the url is not ending with one of the things that I put in the while it's going to return a really ugly addres.. for example
http://www.google.com/ hey dude how are you? great, eating at jack's
My result would be:
http://www.google.com/ hey dude how are you? great, eating at jack
I'm open to suggestions, any of them, I will resume my questions and after that I will post the code
- The code breaks if I don't have the exact ending
- If I put the space " " as a break I'm going to loose all the pages that have space in the address
- I would like to capture all addresses not only the ones starting with http, for example www.google.com is a valida address and so is contacts.google.com
Thanks for everything :D
File txtUrlSpecialFile = new File("pepe.txt");
FileWriter txtUrlSpecial;
txtUrlSpecial = new FileWriter(txtUrlSpecialFile);
txtUrlSpecial.write(profundidad-1);
for(int j=0;j<bigString.length()-5;j++){ //I put 5 but I can put more
if(bigString.substring(j, j+4).equals("http")){
while(bigString.charAt(j)!='"' && bigString.charAt(j)!='<'&& bigString.substring(j, j)!="'"){
txtUrlSpecial.write(bigString.charAt(j));
j++;
}
txtUrlSpecial.write(SingletonFunction.getNewLine());
}
}
txtUrlSpecial.close();