window eclipse 访问远程虚拟机 Hdfs
package com.ibm.w3;import java.net.URI;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FSDataInputStream;import org.apache.hadoop.fs.FSDataOutputStream;import org
·
package com.ibm.w3;
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
public class Dtf {
final public static String HDFS_PATH ="hdfs://dias:9000";
public static final String DIR_PATH ="/d10000";
public static final String FILE_PATH ="/d10000/f11111";
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
final FileSystem fileSystem = FileSystem.get(new URI(HDFS_PATH), new Configuration());
//create folder
//fileSystem.mkdirs(new Path(DIR_PATH));
// upload
//final FSDataOutputStream out=fileSystem.create(new Path(FILE_PATH));
//FileInputStream in = new FileInputStream("C:/workplacebus/business/Important memo.txt");
//IOUtils.copyBytes(in, out, 1024,true);
//download
//final FSDataInputStream in = fileSystem.open(new Path(FILE_PATH));
//IOUtils.copyBytes(in, System.out, 1024, true);
//remove files
fileSystem.delete(new Path(FILE_PATH), true);
}
}
import java.net.URI;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
public class Dtf {
final public static String HDFS_PATH ="hdfs://dias:9000";
public static final String DIR_PATH ="/d10000";
public static final String FILE_PATH ="/d10000/f11111";
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
final FileSystem fileSystem = FileSystem.get(new URI(HDFS_PATH), new Configuration());
//create folder
//fileSystem.mkdirs(new Path(DIR_PATH));
// upload
//final FSDataOutputStream out=fileSystem.create(new Path(FILE_PATH));
//FileInputStream in = new FileInputStream("C:/workplacebus/business/Important memo.txt");
//IOUtils.copyBytes(in, out, 1024,true);
//download
//final FSDataInputStream in = fileSystem.open(new Path(FILE_PATH));
//IOUtils.copyBytes(in, System.out, 1024, true);
//remove files
fileSystem.delete(new Path(FILE_PATH), true);
}
}
----------------------------------------
Eclipse windows 环境配置 请 参考优秀博文 :
http://my.oschina.net/lanzp/blog/309078?fromerr=blt5oYkF
更多推荐
已为社区贡献5条内容
所有评论(0)