전체 컴퓨터 시스템에서 파일을 검색하는 검색 유틸리티를 개발하면 Windows 플랫폼에서 제대로 작동하지만 우분투 리눅스에서는 무한한 프로세스가됩니다. 이 결함을 극복하는 데 도움주세요. 다음은 코드의 주요 부분입니다.자바 코드는 파일 시스템 전체를 검색하고 잘 작동하지만 우분투는 무한합니다
public static void fun(File f){ // root directory is passed as argument
try{
if(f.isDirectory()){
File [] fi=f.listFiles();
for(int i=0;i<fi.length;i++){
if(fileFound==true) break; // fileFound is boolean data type used as flag to indicate whether the file is found or not
System.out.println(fi[i].getName());
fun(fi[i]);
}
}
else{
if(f.getName().equalsIgnoreCase(txtFile.getText()) ||
(f.getName().toLowerCase().startsWith(txtFile.getText().toLowerCase())) ||
(f.getName().toLowerCase().endsWith(txtFile.getText().toLowerCase()))){
l.setText("file found " + f.getAbsolutePath()); // l is JLabel that indicated prints the info like file found and its path
fileFound=true;
}
}
}
catch(Exception e){
}
}
는이 프로그램으로 인해 심볼릭 링크에 일부 순환 종속성을 입력하는 수 있습니까? 또한 빈 캐치를 제거하고 예외를 던지십시오 (어쩌면 랩핑 된). –
"재미"라는 이름의 사람들에게 진지하게 말하지 마십시오. –