Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.HttpURLConnection;
- import java.net.URL;
- public class Ass2 implements Runnable{
- public void run(){
- System.out.println("thread is running...");
- URL url = new URL( "http://localhost:8080/Assign2.php?" );
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- if( conn.getResponseCode() == HttpURLConnection.HTTP_OK ){
- InputStream is = conn.getInputStream();
- // do something with the data here
- }else{
- InputStream err = conn.getErrorStream();
- // err may have useful information.. but could be null see javadocs for more information
- }
- }
- public static void main(String[] args) throws IOException {
- Ass2 m1=new Ass2();
- Thread t1 =new Thread(m1);
- t1.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement