i'm building some program. apache guacamole (VNC tool) makes log in console. (it can be tweak for make log in file, but i won't) so, my program reads log in console and determine which user(id) accessed(connected) or leave(disconnected).
but it gives me "java lang nullpointer exception at line 19". so here is my code.
import java.util.*;
import java.lang.*;
import java.io.*;
class id
{
public static void main (String[] args) throws java.lang.Exception
{
String connect = "connect";
String disconnect = "disconnect";
String id;
int strindex, endindex; //mark start, end index
while(true){
String phrase = System.console().readLine();
if(phrase.equals(""))
continue;
if(phrase.contains(disconnect)){
if( (strindex=phrase.indexOf("- User ")) > -1 )
strindex = strindex + 8;
endindex = phrase.indexOf('"', strindex);
id = phrase.substring(strindex, endindex);
System.out.println(id);
System.out.println("disco\n");
//dockerfile_logout+pause;
}//islogout
else if(phrase.contains(connect)){
if( (strindex=phrase.indexOf("- User ")) > -1 )
strindex = strindex + 8;
endindex = phrase.indexOf('"', strindex);
id = phrase.substring(strindex, endindex);
System.out.println(id);
System.out.println("connected\n");
//dockerfile_login+start!
}//islogin
}//while
}
}