reading a folder

J

jarret.austin

Hi All --

I'm trying to use Java to read the contents of my Temporary Internet
Files "folder", but the File datatype does not seem to be able to see
the contents of the directory (or even the directory itself). I
believe this has to do with the fact that it's a "folder" not a "file
folder" any ideas how to access the contents of this folder using
java?

Thanks,
JA
 
S

SPG

the File object has a listFiles() method.
From there you will get a list of child entries..


File myDir = new File("C:/myDir");
if( myDir.exists() && myDir.isDirectory()){
File[] files = myDir.listFiles()
for(int i=0; i < files.length; i++){
System.out.println(files);
}
}
 
J

jarret.austin

I've tried this but the only the result is only two files:

D:\Temporary Internet Files\Content.IE5
D:\Temporary Internet Files\desktop.ini

But when I view the directory in Windows Explorer there are hundreds of
files (cookies, images, etc).

JA
 
T

Tom Dyess

Hi All --

I'm trying to use Java to read the contents of my Temporary Internet
Files "folder", but the File datatype does not seem to be able to see
the contents of the directory (or even the directory itself). I
believe this has to do with the fact that it's a "folder" not a "file
folder" any ideas how to access the contents of this folder using
java?

Thanks,
JA

It seems like a Windows permissions issue. I got the same results on my box.
I right clicked the folder and the security tab wasn't even available, so it
seems like Windows overrides user control on this folder by default. I'm not
sure if this can be overridden or not, but try google. I tested this on
Windows XP as the administrator account.
 
R

Roland

I've tried this but the only the result is only two files:

D:\Temporary Internet Files\Content.IE5
D:\Temporary Internet Files\desktop.ini

But when I view the directory in Windows Explorer there are hundreds of
files (cookies, images, etc).

JA
That's because Explorer uses a special view to display all those files.

The file "Content.IE5" is actually a directory which contains more
subdirectories with names like "0DS1EJGH" and "UHDE32TW". In those
directories you will find the actual Temporary Internet Files (at least
on my Win2000). The names of the files in these directories are not
exactly the same as you see in the Windows Explorer view (e.g.
"background[1].htm" in the directory vs "background.htm" in Explorer).

You can use Java to delve deeper in to the subdirectories of
Content.IE5, but you cannot get Java to produce the same list as the
Windows Explorer view without using some native Windows OS system call
(you'll have to use JNI for this).
--
Regards,

Roland de Ruiter
___ ___
/__/ w_/ /__/
/ \ /_/ / \
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top