나는 열거하고 분석 할 파일 목록을 포함하는 벡터를 가지고 있으며, 필자의 경우 최선의 선택이 무엇인지 궁금해하고 있었다.자바에서 캐치를 시도하기위한 최선의 선택
내가하고 시작한 일이 :
for (int i =0 ; i< files.size() ; i++)
{
System.out.println("n°" + i + " : " + files.elementAt(i));
try
{
// open the files
}
catch (Exception e) {
// TODO: handle exception
}
}
또는 당신은이 일에 대해 어떻게 생각하십니까?
try
{
for (int i =0 ; i< files.size() ; i++)
{
System.out.println("n°" + i + " : " + files.elementAt(i));
// open the files
}
}
catch (Exception e) {
// TODO: handle exception
}
감사
EDIT:
My purpose is that, when I try to open a file that doesn't exist I must throw something or maybe write the exception in a log file and continu opening the other files.
->
왜 2011 년에'벡터'를 사용하고'목록'또는'세트'를 사용하지 않습니까? –
가능한 복제본 [시도해야 ... 루프 내부 또는 외부에 끼어들 수 있습니까?] (http://stackoverflow.com/questions/141560/should-try-catch-go-inside-or-outside-a-loop) –
String을 그냥 저장하는 경우 Vector를 사용할 때의 문제점은 무엇입니까? –