Method to get all File names in a directory

Hallo together,
has Java any method, to get the file names in a specific directory?
Regards,
Martin

... or simply list() if you're interested in file names only.

Similar Messages

  • Listing of all file names in a directory

    Hello everyone,
    Is there a way to get the listing of all file names in a directory
    pointed by an entry in dba_directory in oracle into a collection in
    pl/sql procedure.
    Thank you.
    Tuncay

    this is the same problem I am trying to solve now. I found some ehlp in Tom Kyte articles on java stored procedures.
    create global temporary table DIR_LIST
    ( filename varchar2(255) )
    on commit delete rows;
    create and compile java source named "DirList" as
    import java.io.*;
    import java.sql.*;
    public class DirList
    public static void getList(String directory)
    throws SQLException
    File path = new File( directory );
    String[] list = path.list();
    String element;
    for(int i = 0; i < list.length; i++)
    element = list;
    #sql { INSERT INTO DIR_LIST (FILENAME)
    VALUES (:element) };
    create procedure get_dir_list( p_directory in varchar2 )
    as language java
    name 'DirList.getList( java.lang.String )';
    then you call in your pl/sql and fill your collection from the DIR_LIST table:
    get_dir_list('the name of the directory' );
    ---then you fill the collection by fetching the DIR_LIST table
    good luck,
    Florin

  • Load all file names in a directory to a SQL Table

    I need to load all the file names in a directory to a SQL table. It must be done via TSQL or SSIS. If using TSQL cannot use xp_cmdshell or any undocumented sprocs. So I am guessing it will be SSIS. But still open to suggestions. I am an SSIS newbie and need
    a nudge in the right direction of how to get the file names into a SQL table.
    Thanks

    Let me add a bit of background. We are sent a group of files. Each file has the ccyymmdd date attached to the name. Possible that we miss processing one day and the next day there are two sets of files in the directory. file1_20140101, file2_20140101,
    file1_20140102, file2_20140102. I cannot guarantee what the file names will be. Just know that i need to process the 20140101 files in one batch, and then the 20140102 files in the next batch. So thinking that i could read all the file names into a SQL table,
    distinct on the date and then sort by the date and pull off those files to process first. Thinking this will be done in SSIS. Open to any ideas or suggestions.

  • Get all file names in a folder, set each as text variable

    First off, I do not know if this is possible.
    For an app I'm writing, I need it to get a list of all the file names inside of a folder, then set a text variable for each of the file names. The app will then display a list of those items, which I know what to do from there.
    If anyone knows how I would be able to do this, or alternatives, I would be extremely grateful.
    Thanks in advance!

    just use any colon separated path (i.e., the desktop would be {color:blue}HD:Users:yourname:Desktop:{colors}) basically, path specifiers come in a number of types:
    # text designations - HD:Users:yourname:Desktop (just a normal text line)
    # posix designations - /Users/yourname/Desktop (how unix expects paths to be written)
    # alias designations - alias "HD:Users:yourname:Desktop" (a pointer to an actual, existing file system element
    # file system referents - file "HD:Users:yourname:Desktop:somefile", folder "HD:Users:yourname:Desktop", etc -
    # file system objects - Folder "Desktop" of folder "yourname" of folder "Users" of disk "HD"
    each has its advantages and disadvantages, and you can coerce between them (though not completely - you need to convert #5 to text before you can convert it to #3, for instance.

  • List all file names in a directory

    Hello everybody,
    I need to write a script in PL/SQL (oracle 10g) that lists all filenames in a specific directory on a client machine and import the files into the database (xml files). After the file is imported they have to be removed.
    I was searching for a solution for this because I have never come accross a challenge like this.
    What I found was that I could use the procedure dbms_backup_restore.searchfiles of the SYS schema.
    Now I need to know how this procedure works. There is very little documentation available.
    Can I give the procedure a folder name on my client computer that has the xml files and let the procedure list these files?
    Can someone please help me with this. I haven't got a clue.
    Thanks in advance.
    regards,
    Mariane

    Hello Justin,
    Thank you for your reply.
    You have just confirmed what I already was thinking: that the server cannot read files from the client.
    I haven't got a client application running to do this. My customer wants me to write a script in PL/SQL that enables users to run an import of xml files in the database by giving in a directory name on the client.
    I told my customer that they have to put the xml files on a server directory. Should that always be the server where the database resides on?
    Is there another way to solve this request?
    Thanks in advance.
    regards,
    Mariane

  • How to read all files' name in a directory and store in a string array?

    as title

    One possibility is to use the listFiles() method, using recursion if you want the files in the sub-directory also. Check API documentation for java.io.File.

  • How to create Dynamic Selection List containg file names of a directory?

    Hi,
    I need a Selection List with a Dynamic List of Values containing all file names of a particular directory (can change through the time).
    Basically, I need an Iterator over all file names in a directory, which could be used for Selection List in a JSF form.
    This iterator has nothing to do with a database, but should get the names directly from the file system (java.io.File).
    Can anybody tell me how to create such an iterator/selection list?
    I am working with JDeveloper 10.1.3.2, JSF and Business Services.
    Thank you,
    Igor

    Create a class like this:
    package list;
    import java.io.File;
    public class fileList {
        public fileList() {
        public String[] listFiles(){
        File dir = new File("c:/temp");
        String[] files = dir.list();
        for (int i = 0; i < files.length; i++)  {
                System.out.println(files);
    return files;
    Right click to create a data control from it.
    Then you can drag the return value of the listFiles method to a page and drop as a table for example.
    Also note that the Content Repository data control in 10.1.3.2 has the file system as a possible data source.

  • Get image file name

    Hi ALL,
    I want all image file naming like a caption in my source document. Source document contains more than 100 images.
    But i got a script through the forum and tuned for my script. Still, the file naming comes for the Ist page image only.
    From second page onwards the file naming not comes like a caption.
    Trying script:
    //To Get image file name
    var tgt = app.activeDocument.rectangles;
    for (i=0;i<tgt.length;i++){
        myCaption = app.activeDocument.textFrames.add();
        myCaption.textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN
        myCaption.contents = tgt[i].graphics[0].itemLink.name
        myCaption.paragraphs[0].justification = Justification.CENTER_ALIGN;
        bnds = tgt[i].visibleBounds;
        myCaption.visibleBounds =
            [bnds[2]+12, bnds[1], bnds[2]+4,bnds[3]];
            //[bnds[0]-6, bnds[1], bnds[0]-1,bnds[3]];
            myCaption.fit(FitOptions.FRAME_TO_CONTENT);
    Thanks in advance
    BEGINNER

    If you use the add() method in conjunction with the document without specifying the page or better the spread, all objects added will end up on the first spread of your document.
    But your testing scenario is also too narrow. You are expecting:
    1. All your graphics are sitting in Rectangle objects (what about Ovals or Polygons?)
    Therefore: All graphics placed in ovals or polygons are left out.
    2. That really ALL rectangles in your document contain graphics
    You are in trouble, if there happen to be empty rectangles on a page. I would suggest to test that with your script. It will give you an error, because there is no graphics[0] for this specific rectangle, where you can draw the "name" for the "itemLink".
    3. That there are no graphics in anchored objects or pasted inside other objects; left alone graphics inside table cells.
    And who can say that thiese three restrictions exist in all documents you want to run this script against?
    So, if you want to get to all image files in the document, why don't you start with the images in the first place?
    Let's see:
    the Document object has an "allGraphics" property.
    Use that as a starting point and you will not missing a single graphic.*
    Iterate through "allGraphics" will get you:
    the "name" of the placed image through its itemLink.name property;
    the container of the graphic, that's the "parent" of the graphic.
    Now you need one other thing:
    the page, or even better(!) the spread where the graphic is located. Imagine a graphic sitting outside of a page.
    If you want to handle thiese, you must know the spread.
    If  writing this script for InDesign CS5 or above, you are in luck. There is a "parentPage" property of the "Graphic" object, you could use for your add() method. For graphics outside of pages this property will be "null".
    And another important thing:
    if a graphic is copy/pasted from e.g. PhotoShop to InDesign, the "itemLink"  property of that graphic is also "null".
    We can handle that in a try/catch scenario…
    //Scope: all graphics on all pages
    //(that includes graphics of anchored objects, active states of MSOs, graphics in table cells as well)
    var tgt = app.activeDocument.allGraphics;
    for(var i=0;i<tgt.length;i++){
        //Narrow the scope to all graphics on pages only:
        if(tgt[i].parentPage != null){
            //What to do with graphics, that are pasted directly from none-InDesign files:
            //the caption will read "Undefined"
            try{
            var myName = tgt[i].itemLink.name;
            }catch(e){var myName = "Undefined"};
            //targets the page of the graphic:
            var myPage = tgt[i].parentPage;
            //adds a text frame to the page of the graphic:
            var myCaption = myPage.textFrames.add();
            myCaption.textFramePreferences.verticalJustification = VerticalJustification.TOP_ALIGN;
            myCaption.contents = myName;
            myCaption.paragraphs[0].justification = Justification.CENTER_ALIGN;
            //Why visible bounds and not geometric bounds?
            var bnds = tgt[i].parent.visibleBounds;
            myCaption.visibleBounds = [bnds[2]+12, bnds[1], bnds[2]+4,bnds[3]];
            myCaption.fit(FitOptions.FRAME_TO_CONTENT);
    *Not exactly true, because it is missing graphics in not-active states of  MultiStateObjects.
    Since MSOs were introduced in InDesign CS5 the DOM documentation left out this fact so far.
    //EDIT: in the first version I had a comment on a different scope. Since  Document Objects have no "graphic" property, I removed that comment. Sorry.
    Uwe
    P.S. And a Happy New Year to all!
    Message was edited by: Laubender

  • How to get all property names and values of an bean instance at runtime?

    How can I get all property names and values of an bean instance at runtime?
    (The class of the bean instance is dynamic and I can not know before I write the code .)

    Look at Class. It has a way to get at all public methods and attributes.
    If you need to get to private attributes you can do what the Introspector does and expect the methods to follow the Bean pattern and pull the attributes out based upon that. Privates are all hidden from direct access but through the Bean Pattern they can be figured out.

  • How is it posible to get the File name, size and type from a File out the H

    How is it posible to get the File name, size and type from a File out the HttpServletRequest. I want to upload a File from a client and save it on a server with the client name. I want to conrole before saving the name, type and size of the file.How is it posible to get the File name, size and type from a File out the HttpServletRequest.
    form JSP
    <form name="form" method="post" action="procesuploading.jsp" ENCTYPE="multipart/form-data">
    File: <input type="file" name="filename"/
    Path: <input type="text" readonly="" name="path" value="c:"/
    Saveas: <input type="text" name="saveas"/>
    <input name="submit" type="submit" value="Upload" />
    </form>
    proces JSP
    <%@ page language="java" %>
    <%@ page import="java.util.*" %>
    <%@ page import="FileUploadBean" %>
    <jsp:useBean id="TheBean" scope="page" class="FileUploadBean" />
    <%
    TheBean.doUpload(request);
    %>
    BEAN
    import java.io.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.ServletInputStream;
    public class FileUploadBean {
    public void doUpload(HttpServletRequest request) throws IOException
              String melding = "";
              String filename = request.getParameter("saveas");
              String path = request.getParameter("path");
              PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("test.java")));
              ServletInputStream in = request.getInputStream();
              int i = in.read();
              System.out.println("filename:"+filename);
              System.out.println("path:"+path);
              while (i != -1)
                   pw.print((char) i);
                   i = in.read();
              pw.close();
    }

    Thanks it works great.
    Here an excample from my code
    import org.apache.commons.fileupload.*;
    public class FileUploadBean extends Object implements java.io.Serializable{
    String foutmelding = "geen";
    String path;
    String filename;
    public boolean doUpload(HttpServletRequest request) throws IOException
         try
         // Create a new file upload handler
         FileUpload upload = new FileUpload();
         // Set upload parameters
         upload.setSizeMax(100000);
         upload.setSizeThreshold(100000000);
         upload.setRepositoryPath("/");
         // Parse the request
         List items = upload.parseRequest(request);
         // Process the uploaded fields
         Iterator iter = items.iterator();
         while (iter.hasNext())
         FileItem item = (FileItem) iter.next();
              if (item.isFormField())
                   String stringitem = item.getString();
         else
              String filename = "";
                   int temp = item.getName().lastIndexOf("\\");
                   filename = item.getName().substring(temp,item.getName().length());
                   File bestand = new File(path+filename);
                   if(item.getSize() > SizeMax && SizeMax != -1){foutmelding = "bestand is te groot.";return false;}
                   if(bestand.exists()){foutmelding ="bestand bestaat al";return false;}
                   FileOutputStream fOut = new FileOutputStream(bestand);     
                   BufferedOutputStream bOut = new BufferedOutputStream(fOut);
                   int bytesRead =0;
                   byte[] data = item.get();
                   bOut.write(data, 0 , data.length);     
                   bOut.close();
         catch(Exception e)
              System.out.println("er is een foutontstaan bij het opslaan de een bestand "+e);
              foutmelding = "Bestand opsturen is fout gegaan";
         return true;
         }

  • How to get Sequence File Name ?

    Hello everybody !!
    I'm using TestStand 3.1 and i would like to get sequence file name. I've tried to use NameOf() function, but without success.
    Of course, I've searched previous posts about the same question, but nothing works.
    Is there someone able to tell me how to get sequence file name ?
    Thanks a lot.
    MrOrange

    MrOrange,
    first of all, the solution i will present only works for saved sequence files.
    you got all information you need within TestStand itself, just browse for RunState.SequenceFile.Path. here you can find the filename. but the path of the file is also included in the string, so this is a part you have to get rid off.
    you can use statements to extract the filename from the path. just search the string for the last occurence of "\\" (searchinreverse!) and then you can retrieve the right() part of the path. beware that right() needs the number of characters you want to extract, not the startindex!!
    hope this helps,
    Norbert B.
    NI Germany
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • FM for getting teh file name with path

    Hi guys,
    Is there an fm getting the file name with path given the physical path and file name? Thanks!

    Hi Mark,
    Function Module WS_FILENAME_GET is obsolete, dont use it.
    Use the Method file_open_dialog of  class cl_gui_frontend_services as given below.
    DATA:
        lt_filetable TYPE filetable,
        lf_rc        TYPE i,
        lv_filename(50) TYPE c,
        lv_fileext(3) TYPE c,
        ls_file TYPE file_table,
        lv_file TYPE localfile,
        lv_title TYPE string.
      lv_title = sy-title.
      lv_progname = sy-cprog.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = lv_title
          file_filter             = '*.txt'
          multiselection          = abap_false
        CHANGING
          file_table              = lt_filetable
          rc                      = lf_rc
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          error_no_gui            = 3
          not_supported_by_gui    = 4
          OTHERS                  = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
                   DISPLAY LIKE 'E'
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        EXIT.
      ENDIF.
    * Number of selected filed must be equal to one.
      CHECK lf_rc = 1.
    * Access selected file
      READ TABLE lt_filetable INTO ls_file INDEX 1.
      CHECK sy-subrc = 0.
      lv_file = ls_file-filename.
      SPLIT lv_file AT '.' INTO lv_filename lv_fileext.
    Revert back if you need clarifications.
    Regards
    Karthik D

  • Get all JNDI names - EJBLocalHome

    Hello,
    I've tried to get all JNDI names that are deployed on the J2EE Server RI Version 1.3.1. It worked fine with the JNDI names of the EJBs with Remote Client view (EJBHome), but did not work with EJBs with local Client View (EJBLocalHome).
    Does anyone knows how could work? Or wether it isn't possible.
    Thanks
    Here's my code:
    InitialContext ct = new InitialContext();
    NamingEnumeration bindings = ct.listBindings("");
    while (bindings.hasMore() ) {
    Binding b = (Binding) bindings.next() ;
    Object object = b.getObject();
    if(object instanceof Context) {
    Context aCon = (Context)object;
    NamingEnumeration n = aCon.listBindings("");
    while (n.hasMore()) {
    Binding b2 = (Binding) n.next() ;
    if (b2.getClassName().equals("javax.naming.Reference")) {
    Object objRef = ct.lookup("ejb/"+ b2.getName());
    if (objRef instanceof EJBLocalHome) {
         System.out.println("localHome");
    //here I want to access the EJBLocalHome Interface
         else if (objRef instanceof EJBHome) {
         System.out.println("Home");
         else                              System.out.println("nothing");
                        

    I use the listBindings() method in order to get all References to a JNDI name. I do not know how to get all JNDI names that are local. How can I check them?

  • Getting absolute file name using af:inputFile

    Hi all,
    Can you help me how to get absolute file name (e.g., C:\Documents\file.txt) using <af:inputFile> component or using any another JSF component.
    Thanks in advance :)))

    we can't get absolute path using inputFile, we can get only the file name. as per my knowledge we don't have any other component also.
    i have one of my requirement i need to read file from specified folder, so i have hard coded my folder name in my managed bean.

  • How get all table name from database

    hi master
    sir
    how get all table name from database

    The big question is 'why'.
    Selecting from view 'dba_tables' will indeed give the list of all tables in the database, but that includes the dictionary tables and the internal tables, and many others that are probably not of interet to a person who needs to ask this question. Besides, the dba_tables view requires access to a DBA account.
    There are several other views: "user_tables" will list all the tables in this user's schema; and "all_tables" will list all the tables this user can access in some way.
    The above do not, of course, include any information about synonyms, sequences, views, indexes and so on.
    The correct answer and the meaningful answer may be two different things.

Maybe you are looking for

  • Saving Dialog Box - how to save to a folder 3 layers deep

    Finally through the leopard install!! 3 times a charm I know this is a really basic question... but how do you save directly to a folder a few layers deep in my folder set up. I click on file save as.... then click on the "where" drop down box but I

  • How can i change credit card information

    how can i change my credit card information or erase the credit card info in my account?

  • Invoking an external webservice in OBIEE 11G

    I'm trying to create a very basic action to invoke an free external web service. But no matter what WSDL URL I use, I'm getting a SOAP Invocation error saying "Failed to read wsdl file at https://.... " I've used the following test URLs, but both res

  • Error during miro

    While i am doing return to vendor using movement type 161, system is giving following message. Account 700020 requires an assignment to a CO object  . I am returning full stock qty to vendor against return Po, since plant has been closed. Here 700020

  • Attachments are missing in Purchase order

    Dear Experts, Users has been attaching files to PO via "Services for Objects" so that approver able to reference some documentation below and they approve the PO.  However, when the approver trying to retrieve them, it "disappear", buyer need to re-a