title: Java program to read objects from a .ser file located in a server
body: <p>My idea is that I want to read an object from a serialized file located in a server. How to do that?</p>
  
  <p>I can only read .txt file using the following code : </p>
  
  <pre><code>   void getInfo() {
      try {
          URL url;
          URLConnection urlConn;
          DataInputStream dis;
  
          url = new URL("http://localhost/Test.txt");
  
          // Note:  a more portable URL: 
          //url = new URL(getCodeBase().toString() + "/ToDoList/ToDoList.txt");
  
          urlConn = url.openConnection();
          urlConn.setDoInput(true);
          urlConn.setUseCaches(false);
  
          dis = new DataInputStream(urlConn.getInputStream());
  
          String s;
          while ((s = dis.readLine()) != null) {
              System.out.println(s);
          }
          dis.close();
      } catch (MalformedURLException mue) {
          System.out.println("Error!!!");
      } catch (IOException ioe) {
          System.out.println("Error!!!");
      }
     }
  </code></pre>