title: How to read from socket using datainputstream
body: <p>I can display a single image received, but now I want to receive and write multiple images on my disk which will be sent from Android client after every 5 seconds.</p>
  
  <pre><code>Socket sock = servsock.accept();
  dataInputStream = new DataInputStream(sock.getInputStream());
  dataOutputStream = new DataOutputStream(sock.getOutputStream());
  System.out.println("Accepted connection : " + sock); 
  
  dataInputStream = new DataInputStream(sock.getInputStream());
  
  byte[] base64=dataInputStream.readUTF().getBytes();
  
  byte[] arr=Base64.decodeBase64(base64);
  
  FileOutputStream imageOutFile = new FileOutputStream("E:\\image.jpeg");
  imageOutFile.write(arr);
  </code></pre>