List all file names in the directory ---ListFiles.java (China2WTO)

xiaoxiao2021-03-06  38

/ * * 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 You can write all file names in your 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-69391.html

New Post(0)