• Log in or sign up for an account here: https://www.sythe.org/login

RSNameChecker

iJava

.Previously known as RSGoldRush
Joined
Nov 21, 2011
Sythe Gold
491
Messages
1,204
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);

            }
        }

    }
}
 
RSNameChecker
Are you new to Java? Why are you extending thread?
 
RSNameChecker
Are you new to Java? Why are you extending thread?

Because it's my thread object and I see no reason to implement runnable instead in this circumstance.
 
Runescape Gamblingrunescape gambling
Back
Top