The number of files under the Java Lookup folder.

Source: Internet
Author: User
Tags stub

Example one, find Java type file

 Packagefile;ImportJava.io.File; Public classJava { Public Static intnum = 0;  Public Static voidMain (string[] args) {//TODO auto-generated Method StubFile File =NewFile ("F:\\crt");            Show (file); System.out.println ("+num+" with "Jar file"); }     Public Static voidShow (file file) {//TODO auto-generated Method Stub         for(File f:file.listfiles ()) {if(F.isfile ()) {if(F.getname (). EndsWith (". dll") ) {num++; }            }Else{show (f); }        }            }}

Example two, find various types of documents and number

 Packageday05;ImportJava.io.File;ImportJava.util.HashMap;ImportJava.util.Map;//programming implementation statistics in a directory, how many kinds of files, respectively, the list is displayed Public classWork04 { Public Staticmap<string,integer> map =NewHashmap<string,integer>();  Public Static voidMain (string[] args) {//TODO auto-generated Method StubShowNewFile ("D:/QQQ")); Map.foreach ((k,v)-{System.out.printf ("%s=%d\n", k,v);            }); }     Public Static voidShow (File dir) {if(Dir.isdirectory ()) {file[] fs=Dir.listfiles ();  for(File f:fs) {if(F.isdirectory ()) {Show (f); }Else if(F.isfile ()) {String n=F.getname (); intpos = N.lastindexof (".")); String ext= pos = =-1? "Unknown file": n.substring (pos+1); if(Map.containskey (EXT)) {map.put (ext, map.get (EXT) )+ 1); }Else{map.put (ext,1); }                }            }        }    }}

The number of files under the Java Lookup folder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.