package will.test;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;

public class TestURI {

private static boolean validateURL( String uri ) {

try {
HttpClient httpclient = new HttpClient();
httpclient.setConnectionTimeout( 1000 );
PostMethod post = new PostMethod( uri );
httpclient.executeMethod( post );

if( 200 == post.getStatusCode() )
return true;
} catch (IOException e) {
e.printStackTrace();
}

return false;
}

/**
* @param args
*/
public static void main(String[] args) {

System.out.println( validateURL( "http://127.0.0.1/~will/podcast/index.html" ) );

}

}

Will(小威) 發表在 痞客邦 PIXNET 留言(0) 人氣()