direcory에있는 하위 폴더에서 (.xxx) 유형의 파일을 읽는 방법을 묻고 싶습니다.Java의 디렉토리 하위 폴더에서 특정 유형의 파일을 읽는 방법
나는 하위 폴더 (하위 폴더의 수를 알 수없는) 파일의
C:\MainFolder
contains-> [subFolder_A][subFolder_B]......[subFolder_n]
모든 하위 폴더 containts 충분히 있지만 그 중 하나는 다른 종류의, 특히 (.fingerprint)가 들어있는 폴더를 유형. \ MainFolder fulled되어 스캔 :
[subFolder_A] --> a.txt , atitle.txt , afin.fingerprint
[subFolder_B] --> b.txt , btitle.txt , bfin.fingerprint
...............................................
[subFolder_n] --> n.txt , ntitle.txt , nfin.fingerprint
그래서 내가 ... 때마다 자바에이 파일 중 하나를 읽을 일부 기능 다음 C까지 다음 하나를 수행합니다.
내가 코드에 직접 경로를 주면 내가 하나를 읽을 수 있지만 사람이 자동 방식
Path path = Paths.get("C:\\MainFolder\\afin.fingerprint");
byte[] data;
byte[] fin;
try {
this.data = Files.readAllBytes(path);
byte[] data = Files.readAllBytes(path);
} catch (Exception e) {....}
fin=data;
죄송는'getFileName' - 그리고 과정은 당신이 작성해야하는 방법입니다! – assylias
{ Files.walk (Paths.get ("C : \ MainFolder")) .filter (p -> p.toFile(). isFile()) .filter (p -> p.getFileName .endsWith ("지문")) .forEach (p -> process (p)); } catch (IOException ex) { Logger.getLogger (main.class.getName()) .log (Level.SEVERE, null, ex); } } static void 프로세스 (경로 p) { System.out.println ("파일을 찾음"+ p.getName); } 뭔가 그 일을 좋아하지 않아 .. 실제로 인쇄 대신 내가 함수를 호출합니다 (인쇄가 발견되면 볼 수있다) –
무슨 일을하지 않았습니까? – assylias