I have the bytes representing a file that I am transmitting over a network. Besides reconstructing the file manually on the file system, how can I get the information from the File, such as getName(), getPath(), etc?
In other words:
- I start out with a File on machine A
- I use FileUtils to turn the file into a byte array
- I transmit that file over a network to machine B
- On machine B, I want to reconstruct that byte[] into a File and run methods such as getName()
The following does not work
- (File) bytes --> Does not convert
- ((File) ((Object) bytes))) --> Does not convert either
I would really rather not create a new temporary file on the filesytem, although I know there are static File.createTemp available that will do that. I'd prefer to just keep it in memory, construct a new File object from the byte[] array, get the information I Need and be done.
Actually, what would be even better is an API that will take the byte[] and from it, directly get the file name by parsing the bits.