Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.net.HttpURLConnection;
  4. import java.net.URL;
  5.  
  6.  
  7. public class Ass2 implements Runnable{
  8. public void run(){
  9. System.out.println("thread is running...");
  10.  
  11. URL url = new URL( "http://localhost:8080/Assign2.php?" );
  12. HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  13. if( conn.getResponseCode() == HttpURLConnection.HTTP_OK ){
  14. InputStream is = conn.getInputStream();
  15. // do something with the data here
  16. }else{
  17. InputStream err = conn.getErrorStream();
  18. // err may have useful information.. but could be null see javadocs for more information
  19. }
  20. }
  21.  
  22.  
  23. public static void main(String[] args) throws IOException {
  24.  
  25. Ass2 m1=new Ass2();
  26. Thread t1 =new Thread(m1);
  27. t1.start();
  28.  
  29.  
  30.  
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement