• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make a JTree show restricted file hiearchies

 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to make a jtree display disabled/hidden file hiarchies. any idea how to do this?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um..what is a disabled file?
The java.io.File already has a convenient isHidden() method.

Pseudo code
1) Start with a root
2) Iteratively extract list of all children under that root
3) Define parent child relationships by creating tree nodes from the files
4) Create a JTree from the nodes and display it

In such scenarios, recursion is always helpful and elegant.
The java.io.File is your friend here.
Check out File#listRoots(), File#listFiles(), File#isDirectory(), File#isHidden()

In case you want to know about tree creation, check this out http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
disabled = not allowed access because admin doesnt allow you to.
 
Rob Spoor
Sheriff
Posts: 20819
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you can't read those period. The operating system is blocking your access, and there is nothing Java can do about that.

You shouldn't even try. If your system admins blocked those folders then they most likely have had a very good reason to do so. If they haven't, ask them to give you permission.

Note: I'm working very closely with our system admin so I'm biased.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is your question about retrieving files not accessible to you or is it about display the file structure as a tree?
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
both. i want to show the files and be able to open/retrieve them.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:Note: I'm working very closely with our system admin so I'm biased.

lol

Rob Prime wrote: Then you can't read those period. The operating system is blocking your access, and there is nothing Java can do about that.

wel that sucks

Rob Prime wrote: You shouldn't even try. If your system admins blocked those folders then they most likely have had a very good reason to do so. If they haven't, ask them to give you permission.

i am doing this for school. i need to acess some files, copy them and such.
 
Rob Spoor
Sheriff
Posts: 20819
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried asking the sysadmins if you can get access to them? If they say no, talk to your professor. If he doesn't back you up you probably don't really need them.
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah... that wont hapen...
 
Cody Long
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i just realized i can use linux to acess anything i want to that is on the hard drive..... still working on the network
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!