title: Sending objects to localhost server using java?
body: <p>How do I create a .ser file or write objects to a .ser file in a localhost server? </p>
  
  <p>The following code can read .ser file : </p>
  
  <pre><code>   public Object deserialize(InputStream is) {
      ObjectInputStream in;
      Object obj;
      try {
          in = new ObjectInputStream(is);
          obj = in.readObject();
          in.close();
          return obj;
      } catch (IOException ex) {
          ex.printStackTrace();
          throw new RuntimeException(ex);
      } catch (ClassNotFoundException ex) {
          ex.printStackTrace();
          throw new RuntimeException(ex);
      }
      }
  
  
          URL url;
          URLConnection urlConn;
          DataInputStream dis;
  
          //url = new URL("http://localhost/Person.ser");
  
          urlConn = url.openConnection();
          urlConn.setDoInput(true);
          urlConn.setUseCaches(false);
          Person person = (person) deserialize(urlConn.getInputStream());
  </code></pre>
  
  <p>Do I need any server side program to receive the object and store in the file?</p>