1

i need to archive lot of files (images) which i need them in my java program, so i'm looking for a way to archive them ( they are too much ! around 30 000 images ) and i don't like to archive them in a file that slow down the access to them for my java program. so what type of files is recomended and how can i archive them and access to them with java. i tried something like this : Adding files to ZIP file, but I'm not sure if is zip files are recomended for my case.

Community
  • 1
  • 1
youssef1700
  • 109
  • 11

3 Answers3

2

If this is not your usecase, feel free to ignore this answer.

I don't know what you need these images for, but 30000 surely is a lot of images.

Ship them packed, unpack at runtime: Minimize shipped size by packing with e.g. LZMA. Note that to stay cross-platform you should ship your own unpacking facility. (ZIP already is included in the JDK, I think) This would allow for faster file access, compared to navigating a .zip file.

Download them at runtime: You could download them at first runtime. If you don't have own servers, try Dropbox, Google Drive etc. The users have to download them anyways (assuming initial download of your program), so this does not add additional bandwidth cost. This also allows you to exchange them over time without a hard update.

Batch them: This is especially popular in game programming. You pack different images into one file (still can have multiple of these, though), therefore limiting the amount of files. An easy way to do this is using the TexturePacker from LibGDX.

Without further information concerning the resolution of the images I can not tell which is the best way for you.

tilpner
  • 4,351
  • 2
  • 22
  • 45
0

Handling large amount of static data (images/JS/CSS etc files) within the application is never a good idea.

The best way is to handle the static data is to package them outside the application hierarchy like e.g some-place in the filing system and then access them there.

Saif Asif
  • 5,516
  • 3
  • 31
  • 48
  • that mean package them into a zip file is not ggod idea and i need to package them in a folder is better ? – youssef1700 Jan 27 '14 at 13:38
  • No ... he is saying that packaging the images as part of your application (i.e. putting them in the JAR file!) is a bad idea. The problem is that your English is .... umm ... difficult to understand. – Stephen C Jan 27 '14 at 13:47
0

It is hard to understand exactly what you are proposing to do. But probably the best way to work out which approach is fastest is to implement both / all approaches, and measure them to see which is fastest.

I agree that embedding the files inside the application is a bad idea ... no matter how you do that. But if you are going to store them outside the application, then there is an obvious trade-off between storing them compressed and/or in archives versus the additional processing needed to store and retrieve them.

What is "best" depends on >>your<< definition of "best" ... and how you need to use these images.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216