🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15860

Re: How can i display directory and filename with jbuilder?

#15860
From: Stefano Reksten
Date: Fri, 23 Apr 1999 00:00
53 lines
2000 bytes
Falcon Spice ha scritto:
> 
> Hello,
>    I want to display directory and filename on local drive and server,
> (something like ws_ftp program) . Now i use TreeControl ,but i cant
> display directory's name and filename on local drive. Please help me.
> 
> best regard,

Hi, here's a little snippet of a piece of a program I wrote for myself.
This small spider starts from a directory and recursively browses it,
calling a 'process()' method only for files (not for directories).
I think you can modify it a bit to suit your needs. (It has been a bit
cut down)

Ciao,
	Stefano

**************************

import java.io.*;

public abstract class DiskSpider {

  protected String base;

  public DiskSpider(String base) {
    this.base = base;
    spider(base);
  }

  private void spider(String base) { // <- base = a file's name
    File fBase = new File(base);
    if (fBase.isDirectory())
      browse(fBase); // <- attach whatever code you want for directories
    else
      process(fBase); // <- attach whatever code for files
  }

  private void browse(File aDir) {
    String [] contents = aDir.list();
    for (int n = 0; n < contents.length; n++)
      spider(aDir.getAbsolutePath() +
System.getProperty("file.separator") + contents[n]);
  }

  protected abstract void process(File aFile);
}

EG

DiskSpider mySpider = new DiskSpider("C:\Winnt");
Technical Details
Message-ID: <372066BE.52812955@sienanet.it>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37045E26.1455FB62@yahoo.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,7d2af48d1b061a74
X-Google-Attributes: gidf74b3,public
From: Stefano Reksten <sreksten@sienanet.it>
Subject: Re: How can i display directory and filename with jbuilder?
Date: 1999/04/23
Message-ID: <372066BE.52812955@sienanet.it>
X-Deja-AN: 469955811
Content-Transfer-Encoding: 7bit
References: <37045E26.1455FB62@yahoo.com>
X-Accept-Language: it
Content-Type: text/plain; charset=us-ascii
Organization: Another Netscape Collabra Server User
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.language