Need help in reading multiple integer input in a line using BufferedReader

I want to read multiple integers in same line. I use this but i am getting nullpointerexception
here’s my snippet:
BufferedReader in = new BufferedReader(new InputStreamReader(;
String[] input =in.readLine().split(" ");
int d1=Integer.parseInt(input[0]);
int v1=Integer.parseInt(input[1]);
int d2=Integer.parseInt(input[2]);
int v2=Integer.parseInt(input[3]);
int p=Integer.parseInt(input[4]);
Please tell me what’s wrong with it and also it will help me alot if you’ll explain me where I went wrong?
Thanks in advance.