Get list of files in a directory

Hello everybody,
working with Oracle 9.2 I have created a directory and i would like to implement in pl/sql a procedure that return the list of files contained.
Anybody know the general solution for this matter?
Thanks in advance

Tom Kyte has an example:
Directory List including modify date and times

Similar Messages

  • Getting list of files from Unix directory inclding files frm sub-directries

    Hi All,
            I am trying to use Fm 'SUBST_GET_FILE_LIST'  and
    'RZL_READ_DIR_LOCAL' for getting a list of all files in a Unix directory including files from sub-directories.
    In the first case I am getting an Exception called 'Access Error'
    and when I use the 2nd FM, I am not getting any output.
    Is there a special way to use these FMs.
    Kindly help.
    Regds,
    Shweta

    [url http://java.sun.com/developer/JDCTechTips/2003/tt0122.html#1]READING FILES FROM JAVA ARCHIVES (JARS)

  • Getting list of files in root directory

    I have seen many forum talking somewhat on this subject but I always see them using c: (for windows) as the example directory. I need to write this so that I can go to a Unix directory.
    Example:
    I want to go to the root directory from where I am....I would use runtime.exec(), right? But does the runtime actually go to that directory or just run the exec?
    If there was a "name" such as c: in unix like windows it would be easier. But, I can not just say the name of the directory is / to get in there and check out the files. So, really what I want to do is if someone is not in the particular directory I want to be able to go to the root directory and check files there, then go to another directory and check the files there, etc.
    I have a hard time explaining things so hopefully someone will get me.
    Thanks.

    But the trouble I am running in to is that I want the
    root directory in Unix, which would be /. I can not
    not just put that as the directory, can i?You can if you spell it out:
    /export/home/thefunnyrootename
    ... or use:
    String sysprop = System.getProperty("whatever property");
    File f = new File(sysprop);... To determine which you want, SDK v1.3.1 docs for System.getProperty():
    getProperties
    public static Properties getProperties()
        Determines the current system properties.
        First, if there is a security manager, its checkPropertiesAccess
    method is called with no arguments. This may result in a security
    exception.
        The current set of system properties for use by the
    getProperty(String) method is returned as a Properties object.
    If there is no current set of system properties, a set of system
    properties is first created and initialized. This set of system
    properties always includes values for the following keys:
        Key Description of Associated Value
        java.version Java Runtime Environment version
        java.vendor Java Runtime Environment vendor
        java.vendor.url Java vendor URL
        java.home Java installation directory
        java.vm.specification.version Java Virtual Machine specification version
        java.vm.specification.vendor Java Virtual Machine specification vendor
        java.vm.specification.name Java Virtual Machine specification name
        java.vm.version Java Virtual Machine implementation version
        java.vm.vendor Java Virtual Machine implementation vendor
        java.vm.name Java Virtual Machine implementation name
        java.specification.version Java Runtime Environment specification version
        java.specification.vendor Java Runtime Environment specification vendor
        java.specification.name Java Runtime Environment specification name
        java.class.version Java class format version number
        java.class.path Java class path
        java.ext.dirs Path of extension directory or directories
        os.name Operating system name
        os.arch Operating system architecture
        os.version Operating system version
        file.separator File separator ("/" on UNIX)
        path.separator Path separator (":" on UNIX)
        line.separator Line separator ("\n" on UNIX)
        user.name User's account name
        user.home User's home directory
        user.dir User's current working directory
    Note that even if the security manager does not permit the getProperties
    operation, it may choose to permit the getProperty(String) operation.
    Returns:
    the system propertiesThrows:
    SecurityException - if a security manager exists and its
    checkPropertiesAccess method doesn't allow access to the system
    properties.See Also:
    setProperties(java.util.Properties), SecurityException,
    SecurityManager.checkPropertiesAccess(), Properties~Bill

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Getting the list of  files in a directory by their last modified date

    Dear friends,
    I want to get the list of files in a directory sorted by their last modified date.
    By default the file.list() or listFiles() return files sorted by their name in ascending order.
    Please give me your suggestions.
    Thanks in advance,
    James.

    Thanks friend,
    I myself got the answer
    here is my code:
    public File[] getSortedFileList(File dir){
    File[] originalList = dir.listFiles();
    int numberOfFiles = originalList.length;
    File[] sortedList = new File[numberOfFiles];
    long[] lastModified = new long[numberOfFiles];
    for(int i = 0; i < numberOfFiles; i++){
    lastModified[i] = originalList.lastModified();
    Arrays.sort(lastModified);
    for(int i = 0; i < numberOfFiles; i++){
    for(int k = 0; k < numberOfFiles; k++){
    if(originalList[k].lastModified() == lastModified[i])
    sortedList[i] = originalList[k];
    System.out.println("The sorted file list is:" + sortedList[i]);
    return sortedList;

  • List all files in a directory on a server that hosts the applet

    Hei :)
    I have a problem. I want to list all files in a directory on my server. ( http://www.foo.bar/tw )
    The applet is in the root folder ( http://www.foo.bar ).
    So i tried it like this
    File fi = new URL(getCodeBase() + "/all/").getFile();But when I try to list the files, I get a SecurityException.
    Can anyone help me out?
    Peace!
    LoCal

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Blist+%2Bfile+%2Bserver

  • List of Files in a directory

    Is there a way that you can get a list of files in a directory that are spelt a certain way? Ex. If in a directory there are html files, txt files, et, In java can I get *.html or a html file with certain text in the name? java.html??
    How you can Help
    US101

    here are the code to list your files
         File startDir = new File("your directory goes here" );
         File[] dirList = startDir.listFiles();
         if (startDir.isDirectory());
         out.print( startDir.getPath() );
              //Start cycling through the array for the file
         for ( int count = 0; count < dirList.length; count++ )
    String fileName = dirList[count].getName();
              int index = fileName.lastIndexOf('.');
              String newString = null;
                   if (index >= 0)
                        newString = fileName.substring(index, fileName.length());
                        if ( newString.equalsIgnoreCase( ".txt"))
                             if ( dirList[count].isDirectory())
                                  out.println( dirList[count].getName() );
                             else
                                  out.println( dirList[count].getName());
                             }//end else
                        }// end if newstring
         }//end if index
         }//end for

  • URGENT : getting attribute of files in a directory

    Hello.
    I use oracle 8i and I want to get attributes of files inside a directory like the "Modified" attribute which indicates the time of creation of the file.
    How can I do this ?
    Thank you very much.

    Tom Kytes has an example with java callout
    Directory List including modify date and times - casting the date problem
    http://asktom.oracle.com/pls/ask/f?p=4950:8:5492560634257383293::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:7506780031005,

  • How to list the files in a directory which are recently modififed few mins

    Hi,
    I need command to list the files in a directory which are modified few minutes ago in SunOS. like "find . -cmin 2 -print " which list files that are modified 2 mins ago in Linux platform.
    Thanks in advance.
    sudha85

    The find command that comes with solaris doesnt have the cmin operator. Only mtime whose option is days.
    So install gnu find from sunfreeware which is the same one that comes with linux.

  • Problem with getting a list of files in a directory

    I'm trying to get a list of files in a particular directory. The problem is I'm also getting a listing of all the sub-directories too. Here is my code:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int i=0;i<filelist.length;i++)
    System.out.println("FileName = " + filelist.getName());
    What am I doing wrong?
    Thanks
    Brad

    You are not doing anything wrong. You just have to test whether a given file is a subdirectory:
    File directory = new File(dir);
    File[] filelist;
    filelist = directory.listFiles();
    for(int n = 0; n < filelist.length; n++) {
      if (!filelist[n].isDirectory())
        System.out.println("FileName = " + filelist[n].getName());
    }S&oslash;ren Bak

  • List of files in a directory of app server

    Hi,
    I was trying to get the list of all files in a directory using fm "EPS2_GET_DIRECTORY_LISTING". But the date column is empty in the output table. I also tried fm's
    SUBST_GET_FILE_LIST
    EPS_GET_FILE_ATTRIBUTES
    none of the above is giving date.
    Can anyone tell me a fm which gives date along with other attributes?
    Thanks in Advance.
    Satish

    try get something from the transaction AL11 source code: RSWATCH0 form -> fill_file_list
    Regards,
    Vincent

  • Getting list of directories within a directory - NULL

    I am getting a NULL POINTER EXCEPTION when trying to get a list of directories from a directory.
    <%
    main_dir = new File("test_dir");
    dirs = main_dir.list();
    if(dir==null){
    %>
    ERROR: dirs is null<p>
    Main Dir: <%=index_dir%>
    <% }
    %>
    It is returning that message that dirs is null.
    The directory structure is
    $TOMCAT_DIR/webapps/test_dir.jsp
    $TOMCAT_DIR/webapps/test_dir
    Within test_dir are two directories: test1, test2
    I put the same code into a regular java code:
    File f = new File ("test_dir");
    String[] dirs = f.list();
    if(dirs == null){
    System.out.println("dirs is null");
    It DOES NOT print out that message that dirs is null.
    I'm just very confused. What am I doing wrong?

    Pardon me but since I don't put the actual code on here sometiems there are typos.
    I have a program where I open a directory. It's a search page where it displays about 10 results then has a button at the bottom says "next" for the next results.
    Anyhow, one minute the webpage will be fine, open the directory with no problem. Then it will stop and say it can't open the directory when the directory is there. It's driving me nuts.
    I'm using Java code within the JSP page, instead of beans so I dont' know if that causes some kind of error.
    <%
    index_dir = new File(master_index_dir);
    indexes = index_dir.list();
    if(indexes==null){
    %>
    ERROR: indexes is null<p>
    Master Index Dir: <%=index_dir%>
    <% }
    else { 
    // Other stuff
    %>
    Well just 5 minutes ago this worked fine, the index was open and the results shown. However just 2 minutes ago it stopped and returns the message that indexes is null.
    Sometimes if I stop and start tomcat several times it starts to work again.

  • List all files in a directory, not including the sub directories if any

    Hi,
    I have been looking around php.net for a bit and can not work
    out how i list the files that are in a directory i.e.
    www.site.com/directory/
    I would like the names of each file to be placed in an array,
    but not to have the sub directories in this list should there be
    any.
    I was given some code a while ago that done this but it
    listed the sub directories and i would like them not in this list.
    I do not have this code anymore and do not know where i got
    it, so i can not get it amended to what i need.
    please can someone tell me what line of code i should be
    using.
    thank you in advance for your help.

    (_seb_) wrote:
    > not very clever wrote:
    >> Hi,
    >>
    >> I have been looking around php.net for a bit and can
    not work out how
    >> i list the files that are in a directory i.e.
    >>
    >> www.site.com/directory/
    >>
    >> I would like the names of each file to be placed in
    an array, but not
    >> to have the sub directories in this list should
    there be any.
    >>
    >> I was given some code a while ago that done this but
    it listed the
    >> sub directories and i would like them not in this
    list.
    >>
    >> I do not have this code anymore and do not know
    where i got it, so i
    >> can not get it amended to what i need.
    >>
    >> please can someone tell me what line of code i
    should be using.
    >>
    >> thank you in advance for your help.
    >>
    >>
    >>
    >
    > The follwoing PHP code will do just that. Just replace
    "pathToFolder"
    > with the path to your folder.
    > I made the list of files also link to each file. Just
    remove the link
    > echo if you don't them to be links.
    >
    > <?php
    > // FUNCTION TO LIST FILES:
    > function listFiles($path){
    > if($handle = opendir($path)){
    > while(false !== ($file = readdir($handle))){
    > if (is_file($path.'/'.$file) &&
    !preg_match('/^\./',$file)){
    > $files_array[]=$file;
    > }
    > }
    > }
    > return($files_array);
    > }
    > $path = 'pathToFolder';
    >
    > // CALL THE FUNCTION:
    > $files_array = listFiles($path);
    > foreach($files_array as $file){
    > echo '<p><a
    href="'.$path.'/'.$file.'">'.$file,'</a></p>';
    > }
    >
    > ?>
    >
    I spotted one error:
    foreach($files_array as $file){
    echo '<p><a
    href="'.$path.'/'.$file.'">'.$file,'</a></p>';
    should be:
    foreach($files_array as $file){
    echo '<p><a
    href="'.$path.'/'.$file.'">'.$file.'</a></p>';
    (a dot after $file, not a coma)
    seb ( [email protected])
    http://webtrans1.com | high-end web
    design
    Downloads: Slide Show, Directory Browser, Mailing List

  • Geting a list of files in a directory

    ok i know how to get it if its in my own drive
    but im haveing trouble doing this from a website.
    im not geting any errors when i try to check the webpage
    on the server it just doesnt even display the applet
    can anyone see what is wrong if i cant see the error's
    i have no way of knowing what im doing wrong
    1.)is url.getPath the correct way to get the path to the directory ?
    2.)can i use the file class as i am to get a list of files on the
    server ?
    String[] availabletexturelist;
    URL url = getDocumentBase();
    String currentpath = url.getPath();
    System.out.println("currentpath = "+currentpath);
    File cdir = new File(currentpath);
    availabletexturelist = cdir.list(new FilenameFilter(){public boolean accept(File d,String name){return name.endsWith(".jpg");}});
    for(int flp = 0;flp < availabletexturelist.length;flp ++){DynamicallyAddTexture(availabletexturelist[flp]);System.out.println(""+availabletexturelist[flp]);} any help is appreciated

    yep my site
    just wanted to be able to have the code read what images are
    in the same directory as the applet and load them all.
    but then the answer would be
    i cant use file to grab a list of files
    that are in the same directory as my applet on the server
    that i am downloading the applet from.
    however is their a way to get the path to just the directory that the
    applet is being downloaded from itself ?
    and then the following is true
    specifying the images that i intend to use in applet parameter tags
    or hardcodeing the imagenames and paths into the code is the easyiest way.
    right ?

  • Reading List of Files in a Directory

    Hi,
    I'm looking for some reference or perhaps an example of how to get LabView to show the files that are in a directory so that the user can choose the appropriate one to load in the run. Right now, I'm running my program with certain specific files in the directory and the list of files written into the program.
    Thank you very much,
    Rob Hal

    I'm sure there are a number of example programs shipped with LV or that could be downloaded from the archives. Anyway, here is a quick example that read a directory content, fills a listbox, and display the selected file content as a string.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Select file.vi ‏57 KB

Maybe you are looking for