Where to store the file extension to retrieve it correctly after decryption I am using Java to write AES-256 to encrypt various files with different extension, the problem is, where am I suppose to store the file extension so the if the data is decrypted, the file extension would be restored ?

For example,

If I encrypt a "test.pdf" file, I will first read it as a byte array and then encrypt it using AES-256, but when the data is decrypted, I can manually save the decrypted data as "xyz.pdf", but this is because I know the original file extension was "pdf". 

What If I don't know what was the extension of the original file before encryption,
If I save the extension inside the encrypted text, then It would only be decrypted with my AES algorithm and wouldn't be decrypted with any another AES-256 algorithm even if the user has a correct key.

So, Where Am I supposed to store the extension of a file?
If you are encrypting one file to one file, simply save the correct extension. Example: open test.pdf, encrypt the content, and save as test1.pdf, or test1.pdf.enc (so that you know that the file is encrypted and any pdf won't try to open it when you double click).

If you are encrypting more than one file together (and, in the end, you have one big chunk of data that contains more than one file inside), you're already having to deal with "which byte belongs to which file", and then storing the original filename is just part of this file manipulation.