I was using this below function and working fine few days before to get the scraps of my orkut friends.
Now a days
i am getting the error below like this
java.net.MalformedURLException: unknown protocol: https
at java.net.URL.<init>(URL.java:508)
at java.net.URL.<init>(URL.java:404)
at sun.net.www.protocol.http.HttpURLConnection.followRedirect(HttpURLCon
nection.java:773)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:570)
at OrkutScraps.get_input_stream(OrkutScraps.java:156)
at OrkutScraps.get_number_of_friends(OrkutScraps.java:123)
at OrkutScraps.main(OrkutScraps.java:70)
java.lang.StringIndexOutOfBoundsException: String index out of range: -43
at java.lang.String.substring(String.java:2044)
at OrkutScraps.get_number_of_friends(OrkutScraps.java:129)
at OrkutScraps.main(OrkutScraps.java:70)
Could you please help me solution for this...
public static String get_input_stream(String url)
{
BufferedReader br;
URL server;
HttpURLConnection connection;
byte b[] = new byte[200];
String abc="";
Date first_scrap_date=new Date();
try
{
server = new URL(url);
connection = (HttpURLConnection)server.openConnection();
//String encodedAuthString ="Basic " + new sun.misc.BASE64Encoder().encode(authString.getBytes());
connection.setUseCaches(true);
//connection.setRequestProperty("Proxy-authorization", encodedAuthString);
connection.setFollowRedirects(true);
connection.setAllowUserInteraction(true);
// This cookie is for s.venkata.reddy@gmail.com. You can set the cookie for your own ID. To get your id cookie follow below steps
connection.setRequestProperty("Cookie", cookiename_and_value);// using the latest cookie value after log in from mozilla getting the cookie value.
connection.connect();
DataInputStream dis = new DataInputStream(connection.getInputStream());
while(dis.read(b)!= -1)
abc=abc+new String(b);
}
catch(Exception e)
{
System.out.println("Http error:");
e.printStackTrace();
return new String("error");
}
return abc;
}