hdfs查看命令_windows命令提示符窗口

hdfs查看命令_windows命令提示符窗口publicclassHdfsClient1{privateFileSystemfs;//初始化一个FileSystem@Beforepublicvoidinit()throwsURISyntaxException,IOException,InterruptedException{//1:获取文件系统URIuri=newURI(“hdfs://myhadoop105:9820”);.

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE稳定放心使用

public class HdfsClient1 {
    private FileSystem fs;
    //初始化一个FileSystem
    @Before
    public void init() throws URISyntaxException, IOException, InterruptedException {
        //1:获取文件系统
        URI uri = new URI("hdfs://myhadoop105:9820");
        Configuration conf = new Configuration();
        conf.set("dfs.replication","6");
        String user = "atguigu";
        fs = FileSystem.get(uri, conf, user);

    }
    @After
    public void closeResources() throws IOException {
        //3:关闭资源
        fs.close();
    }
    @Test
    public void testMkdir() throws IOException {
        fs.mkdirs(new Path("/hdfs/windowsOperator/operator01"));
    }
    @Test
    public void testPut() throws IOException {
        fs.copyFromLocalFile(false , false , new Path("G:/code/test/day08课堂记录.txt") , new Path("/hdfs/windowsOperator/operator01"));
    }
    @Test
    public void testGet() throws IOException {
        fs.copyToLocalFile(new Path("/hdfs/windowsOperator/operator01"),new Path("G:\\code\\test\\test"));
    }
    @Test
    public void testMove() throws IOException {
        fs.rename(new Path("/hdfs/windowsOperator/day08课堂记录.txt"),new Path("/hdfs/windowsOperator/day08"));
    }
    @Test
    public void testDelete() throws IOException {
        fs.delete(new Path("/hdfs/windowsOperator/operator01"),true);
    }

    @Test
    public void testIsFile() throws IOException {
        FileStatus[] fileStatuses = fs.listStatus(new Path("/"));
        for (FileStatus fileStatus : fileStatuses) {
            //判断是否是文件
            if (fileStatus.isFile()){
                System.out.println("-:"+fileStatus.getPath().getName());

            }else {
                System.out.println("d:" + fileStatus.getPath().getName());
            }

        }


    }

    @Test
    public void testListFiles() throws IOException {
        // f:要查看的目录路径
        // r:是否递归查看
        RemoteIterator<LocatedFileStatus> 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.getBlockLocations());
            System.out.println(fileStatus.getPath().getName());

            //快信息
            BlockLocation[] blockLocations = fileStatus.getBlockLocations();
            System.out.println(Arrays.toString(blockLocations));

        }


    }


}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/186043.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 最详细的APAP论文代码分析

    最详细的APAP论文代码分析最详细的APAP论文代码分析代码见:https://cs.adelaide.edu.au/~tjchin/apap/此次实验选用的代码是2013年的版本:由于文档中的代码块截图不一定清楚,需要的可以去上面的网址下载代码对照着看。一、代码1.1、加载文件在程序开始前调用close、clear等函数清除原先工作空间的操作,然后将此次实验所需的文件文件添加到环境中。1.2、编译Mex文件经过对代码块添加测试代码,证明了此处的代码块并未执行,在命令行仅仅输出了对文件的判断,而未输出if-end

    2025年12月8日
    3
  • 关于VUE双向绑定失效的问题「建议收藏」

    关于VUE双向绑定失效的问题「建议收藏」双向绑定失效的原因有很多。lz就说最近遇到的。是的,单价下的那个输入框我用了双向绑定(比如叫price,比如100)。然后ipnut键入中文时,(即使我做了输入验证)。回车时虽然框中不会保留中文,但事实上VUE的双向绑定已经失效了。不管你后面输入什么,绑定的price保存的值只会是中文前的那个值(100)。这样就导致表面好像没事,但是当你提交时就数据不对了。还有

    2025年11月15日
    5
  • Java|JavaScript 模拟钓鱼网站实例一[通俗易懂]

    Java|JavaScript 模拟钓鱼网站实例一[通俗易懂]本次只是用最简单的方法模拟钓鱼网站。前端的代码是从网上下载的,我只是做了稍微的修改。整个项目的源码如下(2018年2月10日在审核估计2月11后可以下载):http://download.csdn.net/download/qq78442761/10247969最后的效果是如下图:输入用户名和密码后,会提醒服务器繁忙然后,我们登录到另外一个页面进行查看:这里涉及如下技术:1.修改网上下载的html…

    2022年8月24日
    7
  • SpringCloud之Zuul网关[通俗易懂]

    SpringCloud之Zuul网关[通俗易懂]Zuul网关

    2022年8月15日
    5
  • html css 分页样式,css中分页样式

    html css 分页样式,css中分页样式css中分页样式css分页样式的设置,我们可以采用ul+li来实现,设置li标签float为left,让它们排列在一行,再设置li标签里面的a标签样式。具体实现如下:部分css代码解释#model14ul{padding-inline-start:0!important;/*设置ul的开头距离为零必面设置自动居中时影响美观*/}#model14li:first-child{mar…

    2022年7月17日
    18
  • JAVA的HelloWorld代码编写

    JAVA的HelloWorld代码编写第一步:新建一个文本文档第二步:打开代码输入代码(注意大小写,Java对大小写很敏感)第三步:更改后缀为.java(这样这个文档就会成为一个原文件)第四步:按住shift键,鼠标右键单击,点击“在此处打开Powershell”第五步:在Powershell窗口里输入JavacHelloworld.java,会出现一个class文档第六步:在Powershell窗口里输入JavacHelloworld会输出HelloWorld…

    2022年5月8日
    455

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号