Java examples for Big Data:Hadoop
Create hadoop FileSystem
import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; public class Task6 { public static void main(String[] args) throws IOException { //String dest = br.readLine(); /*from ww w . j a v a 2 s .c o m*/ Configuration conf = new Configuration(); FileSystem fs =FileSystem.get(conf); OutputStream os = fs.create(new Path(dest)); InputStream is = new BufferedInputStream(new FileInputStream("/home/yourName/hello.txt")); IOUtils.copyBytes(is, os, conf); fs.copyFromLocalFile(new Path("/home/yourName/hello.txt"), new Path("/mydir_hdfs")); } }