How to copy file from HDFS to the local file system of the cluster nodes, in EMR cluster, using java api,

192 Views Asked by At

In EMR cluster, using java api, how to copy file from HDFS to the local file system of the cluster nodes?

1

There are 1 best solutions below

0
Rick On

Did you try using the new Java 7 way of doing it?

https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#copy(java.nio.file.Path,%20java.nio.file.Path,%20java.nio.file.CopyOption...)

e.g.

private static void copyFileUsingJava7Files(File source, File dest) throws IOException {
    Files.copy(source.toPath(), dest.toPath());
}

(From https://www.journaldev.com/861/java-copy-file)

The older way of doing it (java.io.File etc) speaks URIs, so that might be a viable alternative.