construct a cache editor

This is what I am trying to do. Perhaps you can point me in
the general direction because I am confused. I have been
researching sorting methods and I am confused. I want to
take the cache entries which are html gif jpg and class
files mostly and put them into order according to when
they were last modified. I want to display this in a window
like a database but it is an editor. So I will have an html
file followed by the images and java in it in the order.
I want to be able to erase one html file and all the images
and java that go with it so I can edit my cache. I figured
I have to get the file names first and order them; but also
it would be nice if I could look in the html file and extract all the src's and get just the image file names
without the paths and also get all the java class files.
This would be better than just erasing the following
files after the html file. Can you give me some hints and
pointers. Dont ware your brains out with details, just get
me started would be okay. I figure the sort method is in
the java.util but maybe also in the but I do not
see how I demand it to sort in any specific way. I mean
it seems like you just sort and this means alphabetically;
but I want to sort numerically and specifically in the
time and date area. Since the time is measured in seconds
then I must sort the seconds column. Can you help?
Who is Participating?
OK, I don't know how your data is going to be represented when you read it in. But for starters I will assume that you will have the information on File names and times in a Vector. A Vector is convenient for such things since it automatically resizes, and it provides some standard housekeeping methods to boot. Furthermore, then, the files will each be represented by some object, which will then go into the Vector. Each object should implement a Sortable interface (we'll get into that at the end) and the Vector can be sorted by the following routine:

public static void ssort(Vector sv)
{      int gap,i,j,tmp;
      Sortable a,b;

      int l=sv.size();
      for(gap=l/2; gap>0; gap/=2)
      {      for(i=gap; i<l; ++i)
            {      for(j=i-gap; j>=0; j-=gap)
                  { a=(Sortable)sv.elementAt(j);
                    {      sv.setElementAt(b,j);
                    else break;

This is a relatively straightforward implementation of a standard shellsort. A Vector of objects is passed in, and they are rearranged into sorted order. In order to do that, the objects must be sortable, i.e. provide a comp method which will reveal the correct order of any two objects. The Sortable interface would be:

public interface Sortable
{   public int comp(Sortable o);

The shellsort routine assumes that comp returns -1 if a is less than b, 0 if they are equal and 1 if a is greater than b (similar to strcmp in C).

So finally, in this scenario, you would need a file object that provides a comp. It would be something like the following:

public class FileEntry implements Sortable
{    String name;
      long  timestamp;

     ...  (whatever methods you need)

     public int comp(Sortable o)
     {   FileEntry f=(FileEntry)o;

This structure is assuming that the timestamp instance variable  got the timestamp of the file from the lastModified() method in the File class in the io package.. That allows a standard comparison to reveal their ordering.

Let me know if there is anything you need clarified.

There seem to be a bunch of questions here: getting at the cache, identifying pages in pages and sorting. Perhaps you could identify more clearly which you are interested in, or, if it is some or all of them, at least separate them.

johnh619Author Commented:
step 1:get all files names from cache(this could be four caches
in IE-c:/windows/tempor~1/cache1 thru 4)
step 2:sort according to last second of modification(it must
be to the second and not just to the minute)
step 3: take one htm file and either erase all the gif, jpg,
midi, class files from it to the next htm file or, what would
be better would be to extract all the src's file names and
class file names from one htm file and then erase all the files
using this extraction.
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

johnh619Author Commented:
also is this true: that in order to describe the sort method
as either alphbetic sorting or numerical or some type of sorting,
do I have to describe it with logic or is the sort method further
subdivided into types which I can not find. Incidentally I found
this thing call the java explorer which is an applet which
downloads and makes a double window, you can look at the part of
each class file or push the button and access a sun java site
for additional info. I thought maybe it is this additional info
which I desire and which I can not find in books.
johnh619Author Commented:
I hope you got my last reply, it has been a week since I sent it.
But if possibly did not get it then I write again. If you are too
busy I will understand. In the mean time I have been compressing
my site images with Gif Wizard, it really needed it. Now my pages
load almost twice as fast. I paid them $19 for one month unlimited use. Sincerely JohnH

I have no experience with the first two components of the question. I have been working in an application environment for the last year, not applet/browser.

If you want, I can help you with the last question; the sort.

johnh619Author Commented:
Please help me with the sort then and I will resubmit some or
all of the question and let them find someone else to help
perhaps. Thankyou
Incidentally I was wondering: Do you work for this company and
trade your points in for cash and they use this as an incentive
system. I could not imagine what you would do with so many points
and I figured you did not have to ask to many questions yourselfs. Sincerely JohnH
Sorry, I missed you're reply here somehow. Are you still looking for help with the sort?

No, none of the experts work for experts-exchange, nor do we receive any cash. The experts are all volunteers. This site operates more like a bulletin board or newsgroup than anything else. The format just makes it a lot more focussed.

johnh619Author Commented:
yes please help with numberic sort for date and time down to
the second
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.