code: public static void writeObjectToFile(String path, Object toWrite, JavaSparkContext sc) throws IOException {
          writeObjectToFile(path, toWrite, sc.sc());
      }
docs: Write an object to HDFS (or local) using default Java object serialization
  
  @param path       Path to write the object to
  @param toWrite    Object to write
  @param sc         Spark context