当前位置: 首页 > news >正文

贵阳网站备案核验点照相深圳建网站seo

贵阳网站备案核验点照相,深圳建网站seo,门户网站开发注意哪些,wordpress弱口令文章目录 API文档环境配置API操作准备工作创建文件夹文件上传文件下载文件删除文件的更名和移动获取文件详细信息 API文档 HDFS API官方文档#xff1a;https://hadoop.apache.org/docs/r3.3.1/api/index.html 环境配置 将Hadoop的Jar包解压到非中文路径#xff08;例如D:… 文章目录 API文档环境配置API操作准备工作创建文件夹文件上传文件下载文件删除文件的更名和移动获取文件详细信息 API文档 HDFS API官方文档https://hadoop.apache.org/docs/r3.3.1/api/index.html 环境配置 将Hadoop的Jar包解压到非中文路径例如D:\hadoop\hadoop-2.7.2 配置HADOOP_HOME环境变量 配置Path环境变量 API操作 准备工作 创建一个[Maven]工程HdfsClientDemo 引入hadoop-client依赖 dependenciesdependencygrupIdorg.apache.hadoop/groupIdartifactIdhadoop-client/artifactIdversion2.7.2/version/dependencydependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.12/version/dependencydependencygroupIdorg.slf4j/groupIdartifactIdslf4j-log4j12/artifactIdversion1.7.30/version/dependency/dependencies创建HdfsClient 类 创建文件夹 public class HdfsClient {//创建目录Testpublic void testMkdir() throws URISyntaxException, IOException, InterruptedException {//连接的集群nn地址URI uri new URI(hdfs://node1:8020);//创建一个配置文件Configuration configuration new Configuration();//用户String user atguigu;//1、获取到了客户端对象FileSystem fileSystem FileSystem.get(uri, configuration, user);//2、创建一个文件夹fileSystem.mkdirs(new Path(/xiyou/huaguoshan));//3、关闭资源fileSystem.close();} }上面这样写代码有点冗余我们通过AOP切面将初始化和关流的操作拆分出来后续只需要关注核心逻辑就可以了。 实际开发中这样设计也不太好建议搞个工厂类 public class HdfsClient {private FileSystem fs;Beforepublic void init() throws URISyntaxException, IOException, InterruptedException {// 连接的集群nn地址URI uri new URI(hdfs://node1:8020);// 创建一个配置文件Configuration configuration new Configuration();configuration.set(dfs.replication, 2);// 用户String user atguigu;// 1、获取到了客户端对象fs FileSystem.get(uri, configuration, user);}Testpublic void testMkdir() throws URISyntaxException, IOException, InterruptedException {//创建一个文件夹fs.mkdirs(new Path(/xiyou/huaguoshan2));}Afterpublic void close() throws IOException {// 3、关闭资源fs.close();}} 文件上传 Testpublic void testPut() throws IOException {// 参数解读参数1表示删除原数据、参数2是否允许覆盖、参数3原数据路径、参数4目的地路径fs.copyFromLocalFile(false, true, new Path(D:\\bigData\\file\\sunwukong.txt), new Path(hdfs://node1/xiyou/huaguoshan));} 文件下载 //文件下载Testpublic void testGet() throws IOException {//参数的解读参数一原文件是否删除、参数二原文件路径HDFS、参数三Windows目标地址路径、参数四crc校验 // fs.copyToLocalFile(false, new Path(hdfs://node1/xiyou/huaguoshan2/sunwukong.txt), new Path(D:\\bigData\\file\\download), false);fs.copyToLocalFile(false, new Path(hdfs://node1/xiyou/huaguoshan2/), new Path(D:\\bigData\\file\\download), false); // fs.copyToLocalFile(false, new Path(hdfs://node1/a.txt), new Path(D:\\), false);}文件删除 //删除 Test public void testRm() throws IOException {//参数解读参数1要删除的路径、参数2是否递归删除//删除文件//fs.delete(new Path(/jdk-8u212-linux-x64.tar.gz),false);//删除空目录//fs.delete(new Path(/xiyou), false);//删除非空目录fs.delete(new Path(/jinguo), true); }文件的更名和移动 //文件的更名和移动 Test public void testmv() throws IOException {//参数解读参数1原文件路径、参数2目标文件路径//对文件名称的修改fs.rename(new Path(/input/word.txt), new Path(/input/ss.txt));//文件的移动和更名fs.rename(new Path(/input/ss.txt), new Path(/cls.txt));//目录更名fs.rename(new Path(/input), new Path(/output)); }获取文件详细信息 //获取文件详细信息Testpublic void fileDetail() throws IOException {//获取所有文件信息RemoteIteratorLocatedFileStatus listFiles fs.listFiles(new Path(/), true);//遍历文件while (listFiles.hasNext()) {LocatedFileStatus fileStatus listFiles.next();System.out.println(fileStatus.getPath());System.out.println(fileStatus.getPermission());System.out.println(fileStatus.getOwner());System.out.println(fileStatus.getGroup());System.out.println(fileStatus.getLen());System.out.println(fileStatus.getModificationTime());System.out.println(fileStatus.getReplication());System.out.println(fileStatus.getBlockSize());System.out.println(fileStatus.getPath().getName());//获取块信息BlockLocation[] blockLocations fileStatus.getBlockLocations();System.out.println(Arrays.toString(blockLocations));}}
http://www.w-s-a.com/news/814384/

相关文章:

  • 舟山高端网站设计广州优化排名推广
  • 哪个网站做免费广告好上海人才网站
  • cn域名做网站竞价推广代理
  • 省建设干部培训中心网站网站地图1 500 怎么做
  • 制作一个网站需要哪些人网站建设经营服务合同
  • 山东省住房和城乡建设厅官方网站网易发布广州
  • 长沙设计网站效果设计师灵感网站
  • 做网站php都用什么框架把asp.net写的网站别人怎么访问
  • 网站建设捌金手指下拉六正规的代运营公司
  • 自己申请网站空间冀州建网站
  • 哈尔滨旅游团购网站建设江苏建设工程建设网
  • 在郑州做网站茶叶网站建设网页设计制作
  • 58做网站吗南京有关制作网站的公司
  • 申请建设门户网站的申请先做网站还是先申请域名
  • 门户网站怎么做seo玩具外贸好做吗
  • 网页设计模板的网站黄埔营销型网站建设
  • 企业为什么要建立网站江苏高校品牌专业建设工程网站
  • 网站建设公司需要交税么福建省城乡建设厅网站
  • dedecms网站首页网站正在建设中 源码下载
  • 论坛网站有哪些怎么wordpress主题
  • 网站搭建中企动力第一返利的网站怎么做
  • 在哪网站可以做农信社模拟试卷优衣库网站建设的目的
  • 杭州网站建设ttmwl网络平台推广公司
  • 工作室网站技能培训班
  • 东丰网站建设万盛网站制作
  • 安徽黄山网站建设wordpress 公众号 获取密码
  • 自己电脑做网站模板腾讯网站建设分析
  • 如何增加网站反链虚拟主机 2个网站
  • 手机网站调用分享wordpress.org移除
  • 工业和信息化部网站备案系统查询市场调研表模板