2015-05-15 104 views

回答

3

您將需要這些庫,但不需要安裝。使用

SequenceFile.Writer

示例代碼:

import java.io.IOException; 
import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.fs.FileSystem; 
import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.io.NullWritable; 
import org.apache.hadoop.io.SequenceFile; 
import org.apache.hadoop.io.Text; 
public class SequenceFileCreator { 

    public static void main(String[] args) throws IOException { 
     // TODO Auto-generated method stub 
     Configuration config = new Configuration(); 
     FileSystem fs = FileSystem.get(config); 

     SequenceFile.Writer writer = new SequenceFile.Writer(fs, config, new Path("LocalPath"), NullWritable.class, Text.class); 
     writer.append(NullWritable.get(), new Text("")); 
     writer.close(); 
    } 

} 
相關問題