title: How to send custom object using serialization?
body: <p>I'm new to Java. I need to send over socket the file content, together with a double number. My idea is to wrap these two fields into a custom object. Since object File is not serializable, how to send/recv this custom object? Thanks in advance. PS: The sending party will decide if it needs to send the file according to the value of the "double" number. For example:</p>
  
  <pre><code>class MyObject{
      double number;
      File file;
  }
  </code></pre>
  
  <p>When sending, the logic is something like this:</p>
  
  <pre><code>MyObject my = new MyObject();
  
  if(my.number &gt; 0){
      my.file = open_file(aaa.jpg);
  }else{
      //Not opening any file
  }
  
  send(my);
  </code></pre>