Bom dia galera, pedir aqui uma ajuda à vcs, e com JAVA desktop criei um método que faz a leitura de um json em um servidor remoto, porém estou com dificuldades em tratar uma situação, que quando a conexão estiver muito lenta e esse método demorar a responder ele exibe uma mensagem ao usuário informando q a conexão pode está lenta!!! De já muito obrigado
Como você está fazendo a request?
public String Get(String Url, String JSon) throws IOException {
HttpClient client = new HttpClient();
PostMethod post = new PostMethod(Url);
NameValuePair[] data = {
new NameValuePair("JSon", JSon)
};
post.setRequestBody(data);
client.executeMethod(post);
//Aqui ja leio o retorno da pagina
InputStream is = post.getResponseBodyAsStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String Exit = rd.readLine();
String Json2 = "";
while (Exit != null) {
Json2 = Json2 + Exit;
//System.out.println(Exit);
//Resposta.setText(Resposta.getText() + "\n" + Exit);
Exit = rd.readLine();
}
String strOrigem = Json2.replaceAll("", "");
strOrigem = strOrigem.replaceAll("", "");
return strOrigem;
}