aboutsummaryrefslogtreecommitdiff
path: root/other/java/examples/src
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-02-04 21:41:19 -0800
committerChris Lu <chris.lu@gmail.com>2021-02-04 21:41:19 -0800
commit8c3177d835bb86eed6127b390e2f39ca63ba1a04 (patch)
tree761353dc6dee2eff32901be2f58c3a5550ae36ce /other/java/examples/src
parent42e5ef4b0150d339befedb06f6ed23a6c9890296 (diff)
downloadseaweedfs-8c3177d835bb86eed6127b390e2f39ca63ba1a04.tar.xz
seaweedfs-8c3177d835bb86eed6127b390e2f39ca63ba1a04.zip
java: resolve parent directory if started with seaweedfs://
Diffstat (limited to 'other/java/examples/src')
-rw-r--r--other/java/examples/src/main/java/com/seaweedfs/examples/HdfsCopyFile.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/other/java/examples/src/main/java/com/seaweedfs/examples/HdfsCopyFile.java b/other/java/examples/src/main/java/com/seaweedfs/examples/HdfsCopyFile.java
new file mode 100644
index 000000000..006c581c9
--- /dev/null
+++ b/other/java/examples/src/main/java/com/seaweedfs/examples/HdfsCopyFile.java
@@ -0,0 +1,25 @@
+package com.seaweedfs.examples;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.IOUtils;
+
+import java.io.*;
+
+public class HdfsCopyFile {
+ public static void main(String[] args) throws IOException {
+ Configuration configuration = new Configuration();
+
+ configuration.set("fs.defaultFS", "seaweedfs://localhost:8888");
+ configuration.set("fs.seaweedfs.impl", "seaweed.hdfs.SeaweedFileSystem");
+
+ FileSystem fs = FileSystem.get(configuration);
+ String source = "/Users/chris/tmp/test.zip";
+ String destination = "/buckets/spark/test01.zip";
+ InputStream in = new BufferedInputStream(new FileInputStream(source));
+
+ OutputStream out = fs.create(new Path(destination));
+ IOUtils.copyBytes(in, out, 4096, true);
+ }
+}