Text from the array isn't being read
<p>I am trying to create an IRC Bot, below is the code, however, when it runs, it will not detect "001" whatever I try, I'm running it on JRE6 and using JDK6. I'm developing it with Eclipse and using the debug feature to run it. I've tried with both "java.exe" and "javaw.exe". When running, debugex shows 001 is clearly there.</p>

<p>Here is my code:</p>

<pre><code>package bot;
import java.io.*;
import java.net.*;
public class Main {
    static PrintWriter out = null;
    @SuppressWarnings("unused")
    public static void main(String[] args) {
        Socket sock = null;
        BufferedReader in = null;
        try {
            sock = new Socket("irc.jermc.co.cc",6667);
            in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
            out = new PrintWriter(sock.getOutputStream(), true);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        boolean sentconnect = false;
        while(sock.isConnected() == true){
            if(sentconnect == false){
                writeout("NICK GBot");
                writeout("USER GBot GBot GBot :GBot");
                sentconnect = true;
            }
            String data = "";
            try {
                data = in.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            data = data.trim();
            if(data != ""){
                System.out.println("[IN] " + data);
            }
            String[] ex;
            ex = data.split(" ");
            for(String debugex : ex){
                //System.out.println("DEBUGEX: " + debugex);
            }
            if(ex[1] == "001"){
                writeout("JOIN #minecraft");
            }
            try {
                Thread.sleep((long) 0.5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(ex[0] == "PING"){
                writeout("PONG " + ex[1]);
            }
        }
    }

    private static void writeout(String msg) {
        out.println(msg);
        System.out.println("[OUT] " + msg);
    }
}
</code></pre>
