I want to get content of page from URL by this code :
public static String getContentResult(URL url) throws IOException{
InputStream in = url.openStream();
StringBuffer sb = new StringBuffer();
byte [] buffer = new byte[256];
while(true){
int byteRead = in.read(buffer);
if(byteRead == -1)
break;
for(int i = 0; i < byteRead; i++){
sb.append((char)buffer[i]);
}
}
return sb.toString();
}
But with this URL : http://portal.acm.org/citation.cfm?id=152610.152611&coll=DL&dl=GUIDE&CFID=114782066&CFTOKEN=85539315
i can’t get Asbtract :Database management systems will continue to manage…..
Can you give me solution for solve problem ?
Thanks in advance
Outputting the header of of the get request:
This means that the server wants you to download the new locations address. So either you get the header directly from the UrlConnection and follow that link or you use HttpClient automatically which automatically follow redirects. The code below is based on HttpClient: