This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
program that returns all the exe file in the system
Posted by swapnil on November 16, 2000 at 7:17 AM
hello, here is a code for u that accepts two parameters through the command line. First one is the directory from which you want the special type of files(here for eg. the .exe files) Second parameter , is meant for the file extension i.e.here .exe But this program is designed to extract any type of file u wish from a particular directory. The program goes like this.... ................................................................. import java.io.*; public class filefiltering { public static void main(String[] args) { try { File f=new File(args[0]); if(f.exists() && f.isDirectory()) { String s[]=f.list(); for (int i=0;i { if(s[i].endsWith(args[1].toString())) System.out.println(s[i]); } } else System.out.println("No file found with extension "+args[1]); } catch(Exception e) {System.out.println("The error is :"+e.getMessage());} } } ............................................................... hope this helps regards, swapnil .
Replies:
|