Search code examples
javaxmlfile-type

Two applications need to export and import a single file which needs to include data and images, best file type?


I'm making two Java applications one to collect data, another to use it. The one collecting will be importing a file from the other which will include data and images and will be decrypted.

I'm unsure what filetype to use. So far all of the data is in XML and works great but I need the images and was hoping not to have to rely on giving all the images in a folder with a path reference.

Ideas?


Solution

  • well, I think that the best way is to create your own format (.myformat or .data). This file will be in fact a Zip file that contains your XML file and images. There is no perfect example writen in java as far as I know. However, here are some examples :
    Not in java

    • The best example is, as @Bolo said, the odt format. Indeed, OpenOffice writes the doc in an xml file, and the images too. All that is wrapped in an odt file.
    • The .exe file is an other example. The C files and the resources are put in a single file. try to open it with 7-zip, you'll see.
    • The Skyrim plugins are .esp file that contain the dds, the scripts, the niffs (textures)...

    In java

    • The minecraft texture packs are a zip file that contains a .mcmeta file (the infos) and the textures (.png)
    • Jar files are like exe.