1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| try {
//Prepare the connection details
URL ris =
new URL("http://www.xxxxx.com");
System.out.println("filename = " + ris.getFile());
String namf=ris.getFile();
HttpURLConnection conn;
conn = (HttpURLConnection) (ris.openConnection());
String toto = "ok";
if (conn != null)
System.out.println(toto);
conn.setRequestMethod("GET");
//Open connection and retrieve URL content
conn.connect();
InputStream is = conn.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(is));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
} catch (Exception e) {
System.err.println("Exception " + e);
}
} |