construct a cache editor

Posted on 1998-07-06
Medium Priority
Last Modified: 2010-03-30
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 java.io 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?
Question by:johnh619
  • 5
  • 4
LVL 16

Expert Comment

ID: 1224747
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.


Author Comment

ID: 1224748
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.

Author Comment

ID: 1224749
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.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 1224750
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
LVL 16

Expert Comment

ID: 1224751

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.


Author Comment

ID: 1224752
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
LVL 16

Expert Comment

ID: 1224753
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.


Author Comment

ID: 1224754
yes please help with numberic sort for date and time down to
the second
LVL 16

Accepted Solution

imladris earned 100 total points
ID: 1224755
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.


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question