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/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
相关推荐
changjiang 2020-11-16
minerd 2020-10-28
WeiHHH 2020-09-23
Aleks 2020-08-19
WeiHHH 2020-08-17
飞鸿踏雪0 2020-07-26
tomli 2020-07-26
deyu 2020-07-21
strongyoung 2020-07-19
eternityzzy 2020-07-19
Elmo 2020-07-19
飞鸿踏雪0 2020-07-09
飞鸿踏雪0 2020-07-04
xieting 2020-07-04
WeiHHH 2020-06-28
genshengxiao 2020-06-26
Hhanwen 2020-06-25