hadoop范例之HELLOWORLD
hadoop实例之HELLOWORLD新建一个Map/Reduce工程文件:HelloWorld.javaimport java.io.OutputStreamimport
hadoop实例之HELLOWORLD
新建一个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/555.txt"));
String str = "Hello World 555";
out.write(str.getBytes());
out.flush();
out.close();
}
}
在src的目录下创建一个文件夹input及输出文件555.txt,运行java程序,打开555.txt可以看到Hello World 555