```java
public class HadoopClient {
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://hadoop1:9000");
System.setProperty("HADOOP_USER_NAME", "root"); // 以root身份访问
FileSystem fs = FileSystem.get(conf);
fs.copyToLocalFile(false, new Path("/hosts"), new Path("C:\\Users\\Administrator\\Desktop\\"), true);
fs.close();
}
}
```