Skip to content
Advertisement

Skip folder if it does not exists using java

I have created a property file in java named prop.properties inside eclipse.

In prop.properties file, I have added below lines:- users = user1,user2,user3

where user1 , user2 and user3 are folders.

I have created directory named TestDir which contains, user1,user3 folders

Suppose if user2 folder is not present in TestDir, I have to skip that and consider the other folder.

I have used the below code,

JavaScript

But I am getting error. The error is,

JavaScript

Can someone help with resolution

Advertisement

Answer

The problem is getting the count when the directory list is null will fail on the first line. Add a test that sets fileCount to zero in that case. Like,

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement