1.搭建环境
上传、解压eclipse、设置工作目录、新建java工程
2.加入jar包
新建名为lib的folder,将这些目录下的jar包都复制到lib里,然后build path
/opt/software/hadoop-2.6.0-cdh5.14.0/share/hadoop/common
/opt/software/hadoop-2.6.0-cdh5.14.0/share/hadoop/common/lib
/opt/software/hadoop-2.6.0-cdh5.14.0/share/hadoop/hdfs
/opt/software/hadoop-2.6.0-cdh5.14.0/share/hadoop/hdfs/lib
3.新建Package,名为com.hdfs,实现了一些基本操作
package com.hdfs;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileUti