RSNameChecker

Discussion in 'Programming General' started by iJava, Sep 25, 2012.

RSNameChecker
  1. Unread #1 - Sep 25, 2012 at 6:44 AM
  2. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    RSNameChecker

    Decided to create it a month ago when everyone was making one, never tried to sell because it wasn't stable enough but for anyone wanting to know how to do it here's my Thread :

    Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package com.namechecker;
    
    import com.namechecker.gui.MainGUI;
    import java.io.DataInputStream;
    import java.io.IOException;
    import java.net.URL;
    import java.net.URLConnection;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    /**
     *
     * @author Owner
     */
    public class NameChecker extends Thread {
    
        private static final String NAMECHECK_URL = "http://rscript.org/lookup.php?type=namecheck&name=";
        private String username;
    
        private static String readPage(String urlString) {
            try {
                URL url = new URL(urlString);
                URLConnection uc = url.openConnection();
                DataInputStream di = new DataInputStream(uc.getInputStream());
                byte[] buffer = new byte[uc.getContentLength()];
                di.readFully(buffer);
                di.close();
                Thread.sleep(100);
                return new String(buffer);
            } catch (InterruptedException ex) {
                Logger.getLogger(NameChecker.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(NameChecker.class.getName()).log(Level.SEVERE, null, ex);
            }
            return null;
        }
    
        public NameChecker(String username) {
            this.username = username;
        }
    
        @Override
        public void run() {
            if (MainGUI.running) {
                long time = System.currentTimeMillis();
                String html = readPage(NAMECHECK_URL + username);
                if (html.contains(": AVALIBLE")) {
                    if(username.length() > 0 && username.length() <= 12) {
                    MainGUI.namesAvalible.add(username);
                    System.out.println(username + " - A");
                    }
                } else {
                    System.out.println(username + " - N");
                }
                MainGUI.amtNamesChecked++;
                MainGUI.statsLbl.setText("Checked " + MainGUI.amtNamesChecked + "/" + MainGUI.totalAmtNames);
                if (MainGUI.amtNamesChecked >= MainGUI.totalAmtNames) {
                    MainGUI.running = false;
                    System.out.println(System.currentTimeMillis() - time);
                    MainGUI.saveAvalibleNames(MainGUI.outputFilePath);
    
                }
            }
    
        }
    }
    
     
  3. Unread #2 - Oct 23, 2012 at 2:12 PM
  4. Denuo
    Joined:
    Sep 12, 2012
    Posts:
    7
    Referrals:
    0
    Sythe Gold:
    0

    Denuo Newcomer

    RSNameChecker

    Are you new to Java? Why are you extending thread?
     
  5. Unread #3 - Oct 24, 2012 at 12:31 AM
  6. iJava
    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    RSNameChecker

    Because it's my thread object and I see no reason to implement runnable instead in this circumstance.
     
< Visual basic 2008. | Learning python at school then movement to hacking :D >

Users viewing this thread
1 guest


 
 
Adblock breaks this site