title: Convert a text file to sequence format in Spark Java
body: <p>In Spark Java, how do I convert a text file to a sequence file? The following is my code:</p>
  
  <pre><code>    SparkConf sparkConf = new SparkConf().setAppName("txt2seq");
      sparkConf.setMaster("local").set("spark.executor.memory", "1g");
      sparkConf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer");
      JavaSparkContext ctx = new JavaSparkContext(sparkConf);
  
      JavaPairRDD&lt;String, String&gt; infile = ctx.wholeTextFiles("input_txt");
      infile.saveAsNewAPIHadoopFile("outfile.seq", String.class, String.class, SequenceFileOutputFormat.class);
  </code></pre>
  
  <hr>
  
  <p>And I got the error below. </p>
  
  <pre><code>14/12/07 23:43:33 ERROR Executor: Exception in task ID 0
  java.io.IOException: Could not find a serializer for the Key class: 'java.lang.String'. Please ensure that the configuration 'io.serializations' is properly configured, if you're usingcustom serialization.
      at org.apache.hadoop.io.SequenceFile$Writer.init(SequenceFile.java:1176)
      at org.apache.hadoop.io.SequenceFile$Writer.&lt;init&gt;(SequenceFile.java:1091)
  </code></pre>
  
  <p>Does anyone have any idea? Thank you!</p>