title: Kryo read and write generically
body: <p>I found two ways how to read and write using Kryo generically and I am thinking if one of them is better or worse or if they are just the same. </p>
  
  <p>Option 1 - using kryo function writeClassAndObject (readClassAndObject)</p>
  
  <pre><code>public &lt;T&gt; void writeK(T obj, String fileName) {
      checkDir(path);
      Kryo kryo = new Kryo();
      Output output = null;
      try {
          output = new Output(new FileOutputStream(homePath + path + "/" + "kryo_" + fileName + ".bin"));
          kryo.writeClassAndObject(output, obj);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } finally {
          output.close();
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Option 2 - using writeObject (readObject) and Class information</p>
  
  <pre><code>public &lt;T&gt; void writeKryo(Class&lt;T&gt; cl, T obj, String fileName) {
      checkDir(path);
      Kryo kryo = new Kryo();
      kryo.register(cl);
  
      Output output = null;
      try {
          output = new Output(new FileOutputStream(homePath + path + "/" + "kryo_" + fileName + ".bin"));
          kryo.writeObject(output, obj);
      } catch (FileNotFoundException e) {
          e.printStackTrace();
      } finally {
          output.close();
      }
  }
  </code></pre>
  
  <p>It would seem that second option is better because when calling the function I specify what class is that so Java doesn't need to figure out itself. But not sure if that's true or not. According to the speed they seem comparable. Thanks</p>