Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the read operation of java_io_commons file and directory

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report