技术交流qq群: 659201069
本文是hdfs常用的操作工具类,可直接复用!
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
/**
* hdfs常用操作工具类
* @author jianting.zhao
*
*/
public class HdfsUtil {
public static boolean rename(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("error params!");
}
Configuration conf = new Configuration();
FileSystem hdfs = FileSystem.get(conf);
Path src = new Path(args[0]); // 旧的文件名
Path dst = new Path(args[1]); // 新