// 1文件上传
@Service
public class HDFSClient<jsonObjectS> {
public Boolean upload1(InputStream in, String remoteDst) {
Configuration conf = new Configuration();
FileSystem fs = null;
try {
fs = FileSystem.get(new URI("hdfs://192.168.1.102:9000"), conf, "hadoop");
} catch (IOException e) {
e.printStackTrace();
return false;
} catch (InterruptedException e) {
e.printStackTrace();
return false;
} catch (URISyntaxException e) {
e.printStackTrace();
return false;
}
FSDataOutputStream out = null;
try {
out = fs.create(new Path(remoteDst));
} catch (IOException e) {
e.printStackTrace();
return false;
}
try {
IOUtils.copyBytes(in, out, conf);
} catch (IOException e) {
e.printStackTrace();
JAVA 从网页上传文件到HDFS ,单文件上传和多文件上传
最新推荐文章于 2025-08-22 18:24:41 发布
该博客详细介绍了如何使用JAVA从网页直接上传文件到HDFS,包括单文件和多文件的上传方法,主要涉及Hadoop和文件流操作。


607

被折叠的 条评论
为什么被折叠?



