Recupere un fichier via HTTP
Salut !
je voudrais savoir comment faire pour recuperer mon fichier via HTTP ?
j'ai essayer ce code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
new Thread(new Runnable() {
public void run() {
try {
URL url = new URL(jTextField1.getText());
HttpURLConnection data = (HttpURLConnection) url.getContent();
System.out.println(data);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}).start();
} |
mais ca me met une erreur :
Code:
java.lang.ClassCastException: sun.net.www.protocol.http.HttpURLConnection$HttpInputStream cannot be cast to sun.net.www.protocol.http.HttpURLConnection
que faire pour recuperer un fichier via HTTP donc ? merci