How to accessing files in os and display as tree

i have worked lot to access the files in os and display them as tree structure but could not suceed can any one help me

* Light Development Java Library
* Copyright (C) 2003, 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
package com.lightdev.lib.ui;
import javax.swing.JTree;
import javax.swing.tree.TreePath;
import java.io.File;
public class JFileTree extends JTree {
  public JFileTree(File root) {
    super();
    FileTreeModel model = new FileTreeModel(root);
    this.setModel(model);
  public JFileTree() {
    this(new File(System.getProperty("user.home")));
  private String parsePath(TreePath treePath) {
    int pathSize = treePath.getPathCount();
    String path = null;
    for (int i = 0; i < pathSize; i++) {
      if (path == null) {
        path = treePath.getPathComponent(i).toString();
      else {
        path += File.separatorChar + treePath.getPathComponent(i).toString();
    return path;
  public String[] getSelectedUrls() {
    int treepathAmount = getSelectionCount();
    TreePath[] treePaths = getSelectionPaths();
    String[] stringSet = new String[treepathAmount];
    if (treepathAmount != 0) {
      for (int i = 0; i < treepathAmount; i++) {
        stringSet[i] = parsePath(treePaths);
return stringSet;
return null;
* Light Development Java Library
* Copyright (C) 2003, 2004 Ulrich Hilger
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
package com.lightdev.lib.ui;
import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import javax.swing.event.TreeModelListener;
import java.io.File;
import com.lightdev.lib.io.CustomFile;
public class FileTreeModel implements TreeModel {
  public FileTreeModel(File root) {
    this.root = root;
  public Object getRoot() {
    return root;
  public boolean isLeaf(Object node) {
    return ( (File) node).isFile();
  public int getChildCount(Object parent) {
    File[] children = ( (File) parent).listFiles();
    if (children == null)return 0;
    return children.length;
  public Object getChild(Object parent, int index) {
    File[] children = ( (File) parent).listFiles();
    if ( (children == null) || (index >= children.length)) {
      return null;
    return new CustomFile( (File) parent, children[index].getName());
  public int getIndexOfChild(Object parent, Object child) {
    File[] children = ( (File) parent).listFiles();
    if (children == null)return -1;
    String childname = ( (File) child).getName();
    for (int i = 0; i < children.length; i++) {
      if (childname.equals(children)) {
return i;
return -1;
* this tree model is not intended to be editable which is why
* this method is not implemented
* @param path TreePath
* @param newvalue Object
public void valueForPathChanged(TreePath path, Object newvalue) {}
* this tree model is not editable and does not fire events which is why
* this method is not implemented
* @param l TreeModelListener
public void addTreeModelListener(TreeModelListener l) {
* this tree model is not editable and does not fire events which is why
* this method is not implemented
* @param l TreeModelListener
public void removeTreeModelListener(TreeModelListener l) {}
* reference to this tree model's root node (a File)
protected File root;

Similar Messages

  • How to access oracle in javabeans and display the result in jsp

    In my project ,i use the javabean to access the database and do the calculations and i display the result in the jsp page,,,
    any body can help me with your precious codes
    kodi...

    any body can help me with your precious codesStepped in the wrong place, try reading something on JDBC.

  • How to retrieve xml file from BLOB and display on browser with css/xslt

    Hi All,
    I am new to xml. I am storing my xml file into BLOB in database. Now in my jsp page I want to retrieve this xml file from BLOB and display in HTML/CSS/XSLT form...
    Pl. guide me.. any docs..?? Logic...??
    Thanks in Advance.
    Sandeep Oza

    Hello Sandeep!
    I'm not familiar with jsp but logic should be as follows:
    -in jsp page instantiate XML parser
    -load specified BLOB into parser
    Now you may traverse the XML tree or you might load XSL file and use transform method to transform XML according to XSL file.
    I have an example where I'm selecting XML straight from relational database and then transform it using XSL into appropriate HTML output, but it's written in PSP.
    You can try http://www.w3schools.com/default.asp for basics on XML, CSS, XSL. It's easy to follow with good examples.
    Regards!
    miki

  • Accessing sap tables data and display in webi

    Hi all,
    i installed business objects edge series.
    i want to access SAP tables data and display in webi for adhoc reporting.
    Is there any process to achieve this.

    Hi
    currently (April 2010) you have the following options:
    1. You load your R/3 data into an SAP BW and use universes based on BEx queries to create WebI reports
    2. You can use SAP rapid marts. They contain Data integrator mappings (you need an installation of the DI for this) to extract and load your SAP R/3 data into a relational database. Additionally they provide universes (based on a relational schema) hich ill allo you to build WebI reports.
    3. You can use the R/3 connector for the Data Federator (You need a DF installation for this). Please note that the R/3 connector is not yet a product rather just a PROTOTYPE. Take a look here: SAP BusinessObjects Web Intelligence Reporting for SAP ERP [original link is broken]
    4. You can try to access the underlying database directly using the appropriate DB drivers. Please note that this is NOT RECOMMENDED. This way you cannot leverage security defined on the R/3 side in your WebI reports and you will not be able to access all data as available in R/3 since some of them are stored encoded/compressed in the underlying tables.
    5. Instead of WebI you can use Crystal Reports and the R/3 drivers (eg. SAP Tables, Functions, Cluster) provided when installing the integration kit for SAP.
    Regards,
    Stratos

  • How i access file which stored at application server .? Is there any fm ?

    Hi,
    How i access file which stored at application server . Is there any function module which provide same funtinality.
    Regards,
    Gurprit Bhatia

    Hi ,
            U need to use datasets for reading data from application server.Do a f1 on dataset,u will get to know rest of the things.
    TRY.
        OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING UTF-8.
      ENDTRY.
      IF sy-subrc = 0.
          READ DATASET file INTO <wa_data> MAXIMUM LENGTH 200.
               move the data in to internal table
        close dataset
    Edited by: A kumar on Aug 21, 2008 1:37 PM

  • HT204291 how to transfer files between 5C and ipad

    how to transfer files between 5C and ipad data

    iCloud: http://www.apple.com/icloud/features/
    or using a computer, iTunes: http://support.apple.com/kb/ht1296

  • How to access files from two computers on a network, one wired and one wireless?

    I cannot seem to access one computer from the other.  I have marked files for sharing, and both show the same work group.  How do I make sure both computers are installed on the router?

    Make sure that both computers can access the Internet through the router.
    If your router has a setting for "AP isolation", verify that it is set to "disabled".
    As long as you do the two things mentioned above, your router does not put up any barrier to file sharing.   So then the problem is not a router problem, it is a Windows problem, or a firewall problem.
    To check for firewall problem, first, make sure you can ping each computer from the other - if you cannot, then temporarily turn off your software firewall, including Windows Firewall, and see if that helps.
    If you still have problems after the firewall is off, then your problem is likely a Windows problem.   Make sure "file and printer sharing" is enabled on all your wireless adapters and ethernet cards.   If you continue to have problems, then usually the Windows support website has the best info on how to further proceed with fixing this type of problem.
    Hope this helps.

  • Is there a training program for iCloud and how to use it effectively.  I have downloaded the booklet but not sure how I access files, photos saved on iCloud.

    I am trying to understand cloud but have very little information for a non technical person.  Is there any product that I can access that will provide me with step by step details on how to access things stored in Icloud.  I have recenly lost all my data on my external hard drive and thought that I could restore through icloud.

    It doesn't matter whick account you use to download the app.
    You have to sign into the app (or iCloud.com from a web browser on your computer) with his Apple ID & password.
    Find My iPhone will only work if it was enabled in the iCloud settings on the device and it was powered on with a connection to the internet

  • How to access file from AIX server to windows

    HI all,
    My question is how to represent file folder name of that server
    my file folder in AIX server and i want to access that file in window s machine.
    * is this the right way to represent the data folder in physical schema declaration
    file:///<aix server IP>/usr/oracledi/oracldi/data

    No, it is not. Filename magic alone will not do the job.
    AIX supports NFS (network file system) or you can use samba (implementation of the Microsoft SMB protocol to share resources in Un*x) .

  • How to access file from AIX server

    Hi ,
    I am facing a problem with Aix Machine .
    I want to access the file from AIX server machine .I am in Windows machine.
    Regards
    Raghava

    HI all,
    My question is how to represent file folder name of that server
    my file folder in AIX server and i want to access that file in window s machine.
    * is this the right way to represent the data folder in physical schema declaration
    file:///<aix server IP>/usr/oracledi/oracldi/data
    Regards
    Raghava
    Message was edited by:
    Raghava.java

  • How to access files in a jar file?

    Can anyone tell me how to access a file contained in my jar file?
    I have about 15 classes jarred and deployed as an applet. I want to include in the jar file some .gif files to be used as icons in a tree view. Rather than trying to access them locally with all the security headaches this brings, can I not simply jar them as resources and point to them in my code?
    Any help much appreciated,
    Thanks in advance,
    Chris

    Hello Chris,
    Please read this note taken directly from Sun, from their Java Tutorial/Creating a GUI with Swing/Using Other Swing Features/How to use Icons/Specifying the Image Source (whew!)
    Note:  Applets are supposed to be able to load images from JAR files.
    Currently, however, some browsers can't read images from a JAR file,
    although they do successfully get classes from a JAR file.
    With our applets, we currently hedge our bets by both putting
    the image files in the applet's archive file (the JAR file containing
    the applet's class files) and by putting the image files in the file
    system on the server.
    */So......Do you want to take a chance?
    -Ron

  • How to access file server through ethernet BUT internet though wireless

    I'm looking for a way to to run my file server network through ethernet while internet access is provided though wireless, but don't want users to have to switch off the wireless when they want to access the file server.
    File server is set up at trade shows and the conventions charge a fortune for internet access for multiple users and even more ($6000) for a connection that I'm allowed to put a router on. So I'm considering running my apple router for the file server network without internet access and just having my staff get their internet access from the cheaper wireless access the convention center has throughout the building.
    Problem is that I need them to be able to access the file server and the internet at the same time without switching back-and-forth from either network.
    Any suggestions? File server and all clients are macs.
    Message was edited by: Road Show

    Hello,
    Here are some good articles for this topic, please see:
    sql server connectity over the internet:
    http://www.codeproject.com/Questions/433687/sql-server-connectity-over-the-internet
    How To Connect SQL Server Through Internet:
    http://www.youtube.com/watch?v=VOUDdUJ5BLY
    Regards,
    Elvis Long
    TechNet Community Support

  • Photoshop: How to save as a pdf and display description?

    The only other Photoshop I ever used was CS3, and when I clicked "print" it saved as a pdf first, and I could choose to make it display different metadata. That feature has been removed for all newer versions for some reason, and I have no idea how to do what I want to do.
    I need to save it as a pdf, and display the description/subject metadata under the photo. I can't find anything online on how to do this.

    BlazeHeatnix,
    Due to the current unavailability of clairvoyants and mind-readers in the forum, we respectfully request you supply sensible, complete details.
    Please understand that "CS5" does not clear up the issue of what version of Photoshop you are using.  "Photoshop CS5 12.0.1" would.
    A screen capture would be very helpful.
    Also, have you trued the Print command, then Save As PDF?
    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster, who is not a Windows user).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How to access files on internal hard drive

    My Macbook Pro didn't boot so, after I spoke to one of the Apple advisors, I reinstalled the Mavericks on an external HD I had.
    i Was advised that I will be able to access the files on my internal Hd and be able to copy all and saved them before reinstalling the whole computer/internal hd.
    I did what I was told, and after booting my computer through Mavericks which is on external hd I didn't manage to access the files.
    I went to recovery HD to check in disc utility whether my internal HD is still there and it is. And I can see the information about the HD, number of files and etc...
    does anyone have any idea how to access these files and copy them and save the HD somehow?
    make an image of Hd or something?
    I Made a Genius appointment on 19th and I really need the computer...
    help.

    I had some issues with permissions but I managed to sort it out.
    IM moving files separately, not Hd in whole..
    .Moved the desktop first to try if it works and it did.
    now Im moving the whole Home folder...
    IM hoping I wont have a problem moving the applications..?... my whole Adobe is it and I need it..
    SHall I use the Migration assistant later after reinstalling the internal drive...?
    Thank you so much!

  • How to attach file with PR and PO?

    Hi all
    How to attach file (Drawings ,execl,etc..) with PR and PO
    Please help on this
    Thanks
    Regards
    Dhinesh

    Hi
    Thanks
    But If i select  system > service for object in change mode i am getting error "No
    service availale" like that ,how to sort it out and attach the file
    And more ever that icon (service for object) is not coming in change mode ,i selected
    by menu path .How to make it display as icon in bar
    Regards,
    Dhina

Maybe you are looking for