新建一個Map/Reduce工程文件:HelloWorld.java
import java.io.OutputStream;
import org.apache.Hadoop.conf.*;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.*;
public class HelloWorld {
public static void main(String[] args) throws Exception {
Configuration configuration = new Configuration();
FileSystem fs = FileSystem.get(configuration);
OutputStream out = fs.create(new Path("./input/linuxidc.txt"));
String str = "Hello World linuxidc";
out.write(str.getBytes());
out.flush();
out.close();
}
}
在src的目錄下創建一個文件夾input及輸出文件linuxidc.txt,運行java程序,打開linuxidc.txt可以看到Hello World linuxidc