Created
January 7, 2016 17:09
-
-
Save wolny/353b82ef84949ab78855 to your computer and use it in GitHub Desktop.
Simple code snippet for copying a file from local file system to HDFS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import org.apache.hadoop.conf.Configuration; | |
import org.apache.hadoop.fs.FileSystem; | |
import org.apache.hadoop.fs.Path; | |
public class HadoopTest { | |
public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException { | |
FileSystem hdfs = FileSystem.get(new URI("hdfs://localhost:9000"), new Configuration(), "slo"); | |
Path localFilePath = new Path("/home/slo/wireshark.out"); | |
Path remoteFilePath = new Path("/home/hadoop/test.txt"); | |
hdfs.copyFromLocalFile(localFilePath, remoteFilePath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment