• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Peter Rooke
Bartenders:

Not all Images loaded while carving through a File System ?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm sorry for posting an extra Topic, about a former Code. But the Title misleaded.

To the Problem. The Array contains around 60000 Paths. But the resulting Images are only about 1500.

I tried different for each function loops, parallel or ordered. Using some System.out.prints to show the count.
It's still the same it shows around 2000 pictures on the Window.
The count shows around 60000 Image Files and 2000 loaded Images.

The Log Files :
(All Pictures (around 8000 kB)),

(Showed Pictures (around 170 kB)),

((No Access (around 17 kB size)).


How could I figure out where the problems arises, or if it's just in the Nature of the System (Java or Windows) ?



Thanks

Best reagrds,
John
 
Sheriff
Posts: 28536
114
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would definitely fix line 18 so that it doesn't ignore exceptions. You fixed all the other try-catches to throw a RuntimeException, it looks like you just missed fixing this one.
 
Rancher
Posts: 5304
87
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need so many different try-catch blocks - especially when they all (or, erroneously, all but one) do the same thing.  Most all of those could be handled by one big block that covers the main body of the doInBackground() method.  

I would add something like an e.printStackTrace() (or, better, a proper log message) in the catch block.  Normally, you shouldn't do this if you are also rethrowing an exception, as it can lead to excess logged messages.  But that assumes that there's some catch block higher up that will eventually log the error.  If you're not seeing error messages here, it can be good to make extra sure you're not losing them.  Especially when using multi-threading in some way.  You may find that the work is being done in a worker thread that doesn't log errors as you'd expect.

On a related note, the executor.submit() method returns a Future object, which you are currently ignoring.  I recommend collecting these and putting them in a List for later review.  You may find that these Futures are erroring out, or still running, or something else.

Your current code seems to still be doing a lot of the work in one thread, in doInBackground().  Only the code in the executor.submit() lambda expression is actually being delegated to other threads.  That may be a lesser problem, if you're trying to understand why not enough images are being created.  Then again, is it possible that more are still being created, but it's still happening slowly, in the doInBackground() method?  This goes back to the problem that since you're ignoring the returned Future objects, you don't have any way of knowing if this has actually completed yet.  Maybe your GUI just has no way of knowing that more images have been created, later on?
 
Rancher
Posts: 3328
32
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In your previous posting you asked if only certain file types can be displayed.

ImageIO uses a "reader" to read files of a given file type. Not all file types are supported.

You can check which file types are supported by using:



Your previous question also mentioned memory issues. It is not very efficient to use a JLabel to display 60,000 images.

Swing was designed to be used with renderers. So, for example you can use a JList to display the images. In this case only a single JLabel is used to render each image.

I have a very simple  "Thumbnail App" that displays images in a JList. It only loads images from a single directory, so you would need to modify the code to use your filtered list of files. It consists of 5 classes I could post if you are interested.
 
John Tommy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

@Paul Clapham, yes thank you for the Advise, I will reduce the Exceptions and move it to one.
@Mike Simmons, yes thank you for the Advise, I will try to use ExecutorService along with FutureTask.
@Rob Camick, yes thank too for the precious Advise, I will change it accordingly. And I don't mind to send me your Project, I'm glad to test and practice with it.

Sorry, nontheless I read few Books about Java Programming and some still to read I missed to read more about Concurrency and deepen other Stuff, to understand the whole thing.

After tinkering a while, I'm not 100% sure if the Code respects the Rules for this Case. Here my actual Code. It runs, but all Images are recognized as Null ?











Thanks.

Best Regards,
John
 
Rob Camick
Rancher
Posts: 3328
32
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here are the 5 classes.

At the bottom of the ThumbnailApp you should just need to change the filename that contains images you want to load. The app will load all the ".jpg" images found in the directory. This is the class you invoke to start the app.

The ThumbnailWorker using ImageIO to do sampling of the images to make reading of the images faster.

The JList is updated with the thumbnail image as it is loaded.

As you will see the code is similar to yours except is uses a JList to render the images, instead of using individual JLabels.

Have fun.









 
John Tommy
Greenhorn
Posts: 25
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Rob Camick,

Thank you very much for sharing your Code.

I changed the File Carving Part, to iterate recursively through all Folders.

 it works well.

Points to improve :

- Image Rendering (not all Images have the same Resolution, and some are without Image)

- Adding Filepath to the Tooltip.

- Create Logs for Files , accessed, denied, or error reading.

Best Regards,
John
 
John Tommy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Rob Camick,

I changed a bit your Code to add ToolTip with Path instead of only File Name.
Added a SwingWorker Task with FileWalkTree and FileVisitor, to iterate over the whole File System.
Added more File Extension for Images.
Added another Code to create Thumbnails.

Now all Images are viewed. Not as your former Code, which is nontehless great.
However the File System carving takes 8% of CPU Ressource. And after carving it starts to create Thumbnails, which takes about 70-80% of CPU.
Well it works so far, but the percentage of CPU may indicate a problem when using more Programs at the same time on Windows.

I hope to make more of an effort to finish reading the book  (JUnit Tests) and to practice more. So getting more insight in such Problems that could arise.

Thanks.



In ThumbnailRenderer.java


Depending on the purpose of the usage of such a Program.
E.g. I find it useful for searching Files, supected, or missed.
In addition to this, adding a copy Function for the ToolTip Output etc.
Seems more towards a Forensic Tool, however fun because Windows Explorer might take more time to search in C: e.g. for .jpg.

Have a good Time,
John
 
reply
    Bookmark Topic Watch Topic
  • New Topic