大量符号报错:缺少“{”或“}”
import
java.io.IOException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.Client
ProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.fluent.Content;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
public class connect
{
HttpClient client = new DefaultHttpClient();
try {
HttpGet gethttp = new HttpGet("http://www.jwc.bupt.cn/");
String content = null;
HttpResponse response = client.execute(gethttp);
HttpEntity entity = response.getEntity();
if (entity != null)
{
content = EntityUtils.toString(entity);
System.out.println("Response content:" + content);
}
}catch (Exception e) {
e.printStackTrace();
} finally {
client.getConnectionManager().shutdown();
}
}
在下纯小白,还望不吝赐教
------解决方案--------------------你这不是搞笑么,在类里面直接这么写,写到方法里面好吗
------解决方案--------------------3#讲的对的,应该写在方法里面,即在类中写一个方法
------解决方案--------------------
public class connect{
public static void main(String[] args){
HttpClient client = new DefaultHttpClient();
try {
HttpGet gethttp = new HttpGet("http://www.jwc.bupt.cn/");
String content = null;
HttpResponse response = client.execute(gethttp);