Réponse acceptée !
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class HTMLutils {
public HTMLutils(){
}
public static String getHtmlTitleMarkup(String htmlFile){
try {
BufferedReader in = new BufferedReader(new FileReader(new File(htmlFile)));
StringBuilder input = new StringBuilder();
int ch;
while ((ch = in.read()) != -1) input.append((char) ch);
String patternString = "<title>+[^\"]+</title>";
Pattern pattern = Pattern.compile(patternString, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(input);
while (matcher.find())
{
int start = matcher.start();
int end = matcher.end();
String match = input.substring(start, end);
toreturn = match;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return toreturn.substring(7,toreturn.length()-8).trim();
}
public static String toreturn;
}
"
n'est pas mort ce qui semble a jamais dormir et en d'etrange temps meme la mort peut mourrir"