建立一個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