init:
deps-jar:
compile:
run:
Exception in thread “main” java.lang.NullPointerException
at org.HSim.net.HSIP.server.HSIPProtocolHandler.checkInput(HSIPProtocolHandler.java:73)
at org.HSim.net.HSIP.server.HSIPProtocolHandler.(HSIPProtocolHandler.java:39)
at org.HSim.net.HSIP.server.HSIPrunner.Start(HSIPrunner.java:31)
at testofhsip.Main.main(Main.java:30)
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
package testofhsip;
import java.io.IOException;
import org.HSim.net.HSIP.server.HSIPrunner;
/**
*
* @author HandE
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws IOException {
HSIPrunner s = new HSIPrunner();
s.Start();
char[] r = "Hi".toCharArray();
s.write(r);
// TODO code application logic here
}
}
package org.HSim.net.HSIP.server;
import java.io.IOException;
import java.util.logging.Logger;
import org.apache.mina.common.TransportType;
import org.apache.mina.registry.Service;
import org.apache.mina.registry.ServiceRegistry;
import org.apache.mina.registry.SimpleServiceRegistry;
/**
*
* @author HandE
*/
public class HSIPrunner extends Thread {
private static final int PORT = 4444;
private static Logger log =
Logger.getLogger("java.net.HSIP");
HSIPProtocolHandler HSIP;
/** Starts the Server */
public void Start() throws IOException {
HSIP = new HSIPProtocolHandler();
SimpleServiceRegistry registry = new SimpleServiceRegistry();
Service service = new Service("HSIP" , TransportType.SOCKET , PORT );
registry.bind(service , HSIP);
}
public void run() {
//checks Input then sleeps for 100 mileseconds
String IS = null;
try {
while(run = true) {
HSIP.checkInput(IS);
try {
if(HSIP.MaxUserNOReached = true) {
maxNO();
full = HSIP.MaxUserNOReached;
}
this.sleep(100);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
public class HSIPProtocolHandler extends StreamIoHandler {
private static Logger log =
Logger.getLogger("hsipserver");
private int userCount;
/** Creates a new instance of HSIPProtocolHandler */
public HSIPProtocolHandler() {
super();
String IS = null;
try {
checkInput(IS);
} catch (IOException ex) {
ex.printStackTrace();
}
}
InputStreamReader reader;
protected void processStreamIo(IoSession ioSession, InputStream inputStream, OutputStream outputStream) {
try {
reader = new InputStreamReader(inputStream , "ISO-8859-1");
OSW = new OutputStreamWriter(outputStream , "ISO-8859-1");
} catch(UnsupportedEncodingException e) {
}
}
public void checkInput(String IS) throws IOException {
char[] CB = new char[20];
if(CB == null) {
System.out.println("CB null");
}
//line below throws Exception
[u]reader.read(CB , 0 , 20);[/u]
char[] Local = CB;
String pass = String.valueOf(CB , 20 , 7);
String local = null;
local = local.valueOf(Local , 0 , 1);
if(local == "H") {
userCount += 1;
char[] name = null;
String Name = local.valueOf(name , 1 , 10);
newUser(userCount , Name , pass);
}
IS.valueOf(CB);
}