I`m trying to compile a small program for authentication on a torrent site but when it reaches the setRequestProperty() line throws an exception:
Exception in thread "main" java.lang.IllegalStateException: Already connected
at sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(Unknown Source)
at MovieCrawler.main(MovieCrawler.java:22)
I understand that something is already connected! How can I disconnect before using this method;
here is the code:

import java.net.*;
import java.io.*;

public class MovieCrawler {
    public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.torrentleech.org/login.php");
    URLConnection uCon = url.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(uCon.getInputStream()));

    String inputLine;
    while ((inputLine = in.readLine()) != null)
    //for (int i=0;i<20;i++)
    //    System.out.println(uCon.getHeaderFieldKey(i)+": "+uCon.getHeaderField(i));
    //System.out.println("kaaaaaaaaaaaaaa: "+uCon.getRequestProperty("Cookies"));
    String uspass = "***:***"; 
    BufferedReader in2 = new BufferedReader(new InputStreamReader(uCon.getInputStream()));
    inputLine = "";
    while ((inputLine = in2.readLine()) != null)

pls help, I`ve spent several hours finding/creating an working authentication method... and this is my "greate" result :'(

I consider rude to come here and ask for help on project for illigal activities.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.