Witam, chciałem za pomoca wielowatkowosci pobrać źródło adresu url. Adres przesyłam w konstruktorze klasy. Callable zawsze zwraca wartosc w tym przypadku chce by zwracał String. Co robie nie tak? Jako wynik zwraca mi null?
@Override
public String call() throws Exception {
String html;
URL myUrl = new URL(x);
BufferedReader in = new BufferedReader(new InputStreamReader(myUrl.openStream()));
while ((html = in.readLine()) != null) {
html += html;
}
return html;
}
ExecutorService service = Executors.newSingleThreadExecutor();
Future<String> future1 = service.submit(new site("http://wp.pl"));
String data1 = future1.get();
System.out.println(" Wynik to " + data1);