Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the read operation of java_io_commons file and directory

Shulou Source: shulou.com Published: 2022-06-02 11:37:31 10月02日 Update

This article mainly introduces how to achieve the java_io_commons file and directory reading operation, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

/ / File size long len=FileUtils.sizeOf (new File ("C:/Users/10853/eclipse-workspace/_io_commons/src/_io_commons/commons.java")); / / Directory size long dir=FileUtils.sizeOf (new File ("DRAUGUGUM d"))

Operation of the directory:

/ / list descendants, the first is the file object, the second is the operation related to folder filtering (such as filtering out the operation with the suffix .txt), and the third is the filtering operation / / return type of the directory is a Collection container / / only traverses the next layer of non-empty files by default That is, the second parameter, EmptyFileFilter.NOT_EMPTY, is the third parameter, null Collection files= FileUtils.listFiles (new File ("Dazzard paddle d"), EmptyFileFilter.NOT_EMPTY, null). For (File file:files) {System.out.println (file.getAbsolutePath ());} / / all non-empty grandchild files Collection files2=FileUtils.listFiles (new File ("Dreshab d"), EmptyFileFilter.NOT_EMPTY, DirectoryFileFilter.INSTANCE); for (File file:files2) {System.out.println (file.getAbsolutePath ()) } / / specify the suffix file Collection files3=FileUtils.listFiles (new File ("Dju txt d"), new SuffixFileFilter ("txt"), DirectoryFileFilter.INSTANCE); for (File file:files3) {System.out.println (file.getAbsolutePath ()) } / / specify multiple suffixes and empty files Collection files4=FileUtils.listFiles (new File ("Dju java d"), FileFilterUtils.or (new SuffixFileFilter ("java"), new SuffixFileFilter ("txt"), EmptyFileFilter.EMPTY), DirectoryFileFilter.INSTANCE); for (File file:files4) {System.out.println (file.getAbsolutePath ()) } Thank you for reading this article carefully. I hope the article "how to read java_io_commons files and directories" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Files directories articles suffixes three parameters size descendants relevance values interests simultaneously multiple containers objects folders more friends knowledge types Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS OPPO Reno Docker Shulou Technology Microsoft