zoukankan      html  css  js  c++  java
  • hadoop编程实践

    package test.hdfs;
    
    import java.io.IOException;
    import java.net.URI;
    
    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.FileSystem;
    import org.apache.hadoop.fs.Path;
    
    /*
     *  @authr:Kouch
     *  
     *  功能:变成实现判断hdfs上文件是否存在;
     *  
     *  实现:调用hadoopAPI;
     * 
     */
    public class IsExsit {    
        
        //main
        public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
            //配置类
            Configuration conf=new Configuration();
            
            //模拟路径;
            String url="hdfs://localhost:9000/user/kouch/input";
            
            //文件系统对象
            FileSystem fs=FileSystem.get(URI.create(url), conf);
            
            if(isExsit(fs,url)) {
                System.out.println(url+"存在");
            }else {
                System.out.println(url+"不存在");
            }
            
        }
        
        //判断方式
        public static boolean isExsit(FileSystem fs,String path) {
            boolean is=false;
            try {
                is=fs.exists(new Path(path));
            } catch (IllegalArgumentException | IOException e) {
                e.printStackTrace();
            }
            return is;
            
        }
        
    }
    ...................................................
  • 相关阅读:
    linux内核启动汇编部分详解
    linux内核zImage详解
    Linux内核zImage怎么来的?
    Linux内核编译make做了什么?
    关于makefile的几点经验
    note
    tmp0000
    tmp
    SSL学习与总结
    C++学习笔记
  • 原文地址:https://www.cnblogs.com/floakss/p/11455801.html
Copyright © 2011-2022 走看看