0
다음은 코드입니다. 나는 한 번만 닫기를 호출하여 바로하고 있나? 그것을 reinstantiate 경우다시 인스턴스화하는 경우 FileInputStream을 여러 번 닫아야합니까?
public class SeatTest extends TestCase {
FileInputStream inputStream;
ArrayList<File> fileNames = new ArrayList<>();
@SuppressWarnings("unchecked")
@Override
protected void setUp() throws Exception {
File dir = new File("./data/test/seat_layouts");
fileNames = new ArrayList<File>(Arrays.asList(dir.listFiles()));
}
@Test
public void testParse() throws IOException {
for (File file : fileNames) {
inputStream = new FileInputStream(file);
String everyThing = IOUtils.toString(inputStream, "UTF-8");
//do something
}
}
@Override
protected void tearDown() throws Exception {
if (inputStream != null) {
inputStream.close();
}
}
}
도전적으로 종료해야합니다. – BDR