Discuss / Java / hello cao

hello cao

Topic source

#1 Created at ... [Delete] [Delete and Lock User]

package Qiantao;

import java.io.File;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

public class PrintFilePath {

public static void main(String[] args) {

// TODO Auto-generated method stub

String basicpath="d:\\test\\";

printpath(basicpath);

}

public static void printpath(String path)

{

File f = new File(path);

File[] fs1 = f.listFiles();

for (File n : fs1) {

if(n.isFile()) 

{System.out.println(n.getName());}

else {

System.out.println(n.getName()+"\\");

printpath(n.getAbsolutePath());

}

}

}

}


  • 1

Reply