2015-02-04 2 views
2

중 하나가 말해 줄 수 언급 한 특정 위치에 존재하는 파일 이름을 얻기 위해는 어떻게 특정 위치에 존재하는 파일 이름을 얻을 수있는 방법

E:/abc_RESPONSE/Response_을 말한다.

나는 반환이 추상 경로명이 가리키는 파일이나 디렉토리의 이름을 의미 경로명의 이름 순서의 마지막 이름을 반환합니다

java.io.File.getName()

방법을 사용했습니다. 하지만 특정 위치에있는 모든 파일 이름이 필요합니다.

String name = (String)(new File("E:/abc_RESPONSE/Response_").getName()); 

위의 코드를 사용하여 구현하고 있습니다.

답변

2

이 시도하려고 ..

public void listFiles(String directoryName){ 

     File directory = new File(directoryName); 

     //get all the files from a directory 

     File[] fList = directory.listFiles(); 

     for (File file : fList){ 

      if (file.isFile()){ 

      System.out.println(file.getName()); 

      } 

     } 

    } 
1

String[] names = new File("E:/abc_RESPONSE/Response_").list(); 
관련 문제