java - Scan all the files and Display the name and path of the file with the maximum size -


it program (java) uses system calls extract basic information related system.

scan files , display name , path of file maximum size

can please confused system calls. thanks

this tou need. should read documentation file api . http://docs.oracle.com/javase/7/docs/api/java/io/file.html

public class listfiles  {      public static void main(string[] args)      {          // directory path here         string path = ".";           string files="";         double maxbytes = 0;         file folder = new file(path);         file[] listoffiles = folder.listfiles();           (int = 0; < listoffiles.length; i++)          {              if (listoffiles[i].isfile() && listoffiles[i].length()>maxbytes)              {                 maxbytes = listoffiles[i].length()                 files = listoffiles[i].getname();             }         }         system.out.println(files);     } } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -