please help to debug error
 
I tried to execute following client server program.
server program
import java.net.*;
import java.io.*;
public class serv
{
    public static void main(String args[])throws IOException
    {
        ServerSocket ser=new ServerSocket(1233);
        Socket cli;
        System.out.println("waiting for connection...........");
        cli=ser.accept();
        System.out.println("connected");
        DataInputStream fromsock=new DataInputStream(cli.getInputStream());
        String file=new String (fromsock.readLine( ));
         DataOutputStream tosock=new
DataOutputStream(cli.getOutputStream());
        System.out.println("file from client" +fromsock.readLine());
        fromsock.close();
        tosock.close();
    }
}
client
import java.net.*;
import java.io.*;
public class cli
{
    public static void main(String args[]) throws IOException
    {
        Socket cli=new Socket(InetAddress.getByName("localhost"),1233);
        System.out.println("connected by client");
         DataInputStream dis=new DataInputStream(System.in);
         DataOutputStream dos=new DataOutputStream(cli.getOutputStream());
         String inp=dis.readLine();
        dis.close();
        dos.close();
    }
}
it shows exceptions:
Exception in thread "main" java.lang.NullPointerException
        at java.lang.String.<init>(String.java:141)
        at serv.main(serv.java:14)
please help me to solve this problem and tell me reason why it happens