title: Why is my serializable java class producing a serialized file thats larger than the normal file?
body: <pre><code>import java.io.FileOutputStream;
  import java.io.FileReader;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  
  import java.util.List;
  
  import com.opencsv.CSVReaderBuilder; 
  
  
  public class NormalJava implements Serializable{
  
  private static final long serialVersionUID = 7526472295622776147L;
  
  static String Filename = &quot;/Users/tarunv711/Desktop/ads.csv&quot;;
  
  static String outFile = &quot;/Users/tarunv711/Desktop/TV.txt&quot;;
  public static void main(String[] args)
  {readAllData(Filename, outFile);
  }
  
  public static void readAllData(String Filename, String outFile) {
          
          try { 
                
              // Create an object of filereader class 
              // with CSV file as a parameter. 
              FileReader filereader = new FileReader(Filename); 
    
              // create csvReader object 
              // and skip first Line 
              com.opencsv.CSVReader csvReader = new CSVReaderBuilder(filereader) 
                                        .build(); 
              
  
  
              
              List&lt;String[]&gt; allData = csvReader.readAll(); 
              
              ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(outFile));
              // print Data 
              for (String[] row : allData) { 
              
                  os.writeObject(row);
              } 
              os.close();
              System.out.println(&quot;Done&quot;);
          } 
          catch (Exception e) { 
              e.printStackTrace(); 
          } 
      
  }
  }
  </code></pre>
  <p>The class runs perfectly fine and produces a file, but the file in this example after being serialized was 9KB, when the starting file was 6KB. When I tried it with other files as well, the same result persisted. I'm using the java serializer.</p>