I receive encrypted data files into a directory where they are unencrypted by a nightly process.
The unencrypted files are then loaded.
I need to write a Java method to return an array containing the filenames of all the unencrypted files in the directory.
The encrytion method is openSSL (aes128).
So far I have tried getType() but it returns content/unknown for both the unencrypted data files and the encrypted file too.
I am now looking into reading the first two lines of each file and checking the characters returned to see if the file is encrypted.
What I need to know is, is there a better way of doing this?
I could also live with testing whether the file contents are XML or plain text rather than testing whether the file is encrypted if that makes the solution easier?
Use a naming convention so the decrypted files have a different extension, or put the decrypted files in a different directory.
Edit: given the constraints you mention, I think you’ll have to do what you suggest in the question. This http://www.dansdata.com/gz125.htm is an interesting guide to the problems of file identification. You could also shell out to the
fileunix command if it works with your particular file types.