List all file names in the directory ---Listfiles.java

xiaoxiao2021-03-06  56

/ * * CREATED ON 2004-12-9 * I haven't found this function in which common software, so write this class * You can list the files in the disc in the TXT file, easy to find, or print come out. * Don't have to find a disc to find a disc for a certain disc and a slow and sluggish drive. * Of course, you can also choose a directory to record all file names under the directory. * /

/ ** * @Author SHI Weifeng * listFiles class Class all file names in the directory into your specified text file. * / import java.io. *; public class listfiles {private static string listfilestr = ""; public static void main (String [] args) {Try {file savefile = new file (args [1]); FileWriter FW = New FileWriter (Savefile); Listfiles LF = New ListFiles (); lf.listfile (Args [0]); fw.write (); fw.close ();} catch (arrayindexoutofboundsexception EA) {// Parameter Tips System.out .println ("USAGE: LISTFILES ");} Catch (IOException E) {System.out.Println ("IO Error! / R / N" E.TOSTRING ());}

} Public void listfile (String rp) {file file = new file (rp); file list [] = file.listfiles (); for (int i = 0; i

}

转载请注明原文地址:https://www.9cbs.com/read-82492.html

New Post(0)