I want to check whether any Zip file is present on a specified path. If present then I want to extract that file on the same path.
How to check if any Zip file is present on a given path?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can try this code which checks the extension of the file inside the directory and prints the filename if Zip file is present.
Instead of that If you want to use
FilenameFilteras told by Andrew Thompson.You can implement FilenameFilter in your class.
More help is given on this link.
By this you dont need to check the extension of file .
It will give you only those files which extension is being passed as a parameter.
To extract the zip file if found you can take help of the
ZipInputStreampackage .You can have a look here to extract the folder.