Witam, mam pewien kod. Robi on konto na pewnej stronie, ale nie za bardzo go rozumiem. Wiem jedynie jak zmienić parametry tworzonego konta. Mam za sobą jedynie podstawy javy. Mam pewne swoje przypuszczenia co - co robi ale szukając w necie nie za wiele się dowiedziałem. Więc proszę o skomentowanie linijki po linijce co się tu dzieje.
import java.io.*;
import java.net.*;
import org.omg.CORBA.portable.InputStream;
public class Hakier{
public static void main(String[] args) throws Exception{
String urlParameters = "account=100600&nick=hakip&pass=test123&sex=1&vocation=1";
String request = "http://evoevo.no-ip.org/?body=create";
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setInstanceFollowRedirects(false);
connection.setRequestProperty("Referer", "http://evoevo.no-ip.org/?body=acc");
connection.setRequestProperty("Connection", "keep-alive");
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("charset", "utf-8");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setUseCaches (false);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream ());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
java.io.InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while((line = rd.readLine()) != null) {
response.append(line);
response.append('\r');
}
rd.close();
System.out.println( response.toString());
connection.disconnect();
}
}
@refresh
Na prawdę to jest takie skomplikowane? :/