Runtime Error

I was facing some Runtime Errors. Below is the code, for which I am getting java.lang.NullPointerException in the last line:-
15 r = new
16 (;
17 String a= r.readLine();
18 int x= Integer.parseInt(a.substring(0,a.indexOf(’ ')));
I cannot understand why there is an exception, although it is perfectly working in the offline IDE I use. Can you please tell how to resolve the problem?
Also, I wanted to know whether there are special differences between offline IDEs and Codechef IDE. Please tell me.