Selecting all files from a directory in a JFileChooser

Hello all...
i m trying to make an application in which i simply print all the files in a directory and their path on clicking and selecting the directory or by pressing the open button of the JFileChooser.
Any help would be highly appreciated.
Thanx.
Salman

Yet another multi post:
http://forum.java.sun.com/thread.jspa?messageID=3529802

Similar Messages

  • How can I create a array with all files from a directory

    How can I create a array of files or varchar with all files from a directory?

    I thought the example could be improved upon. I've posted a solution on my blog that doesn't require writing the directory list to a table. It simply returns it as a nested table of files as a SQL datatype. You can find it here:
    http://maclochlainn.wordpress.com/2008/06/05/how-you-can-read-an-external-directory-list-from-sql/

  • How to select all files from the application server.

    Hi all,
    I have  a requirement to select all files with the same file format I.e i have created no of files with same name but different time stamps addition , now i want to select all the fiels and read the data into an internal table and sort them on the user requirement,  I am using FM -
    /SAPDMC/LSM_F4_SERVER_FILE to get single file name, i should also give the option on the  selection screen for the user to select the file range I.e form which to which the sorting should be done.
    could anybody suggest me the function module which selects all the file names .
    Regards,
    Sre.
    Edited by: Alvaro Tejada Galindo on Mar 10, 2008 4:49 PM

    Hi,
    PARAMETER: p_fdir type pfeflnamel DEFAULT '/usr/sap/tmp'.
    data: begin of it_filedir occurs 10.
    include structure salfldir.
    data: end of it_filedir.
    *START-OF-SELECTION
    START-OF-SELECTION.
    Get Current Directory Listing for OUT Dir
    call function 'RZL_READ_DIR_LOCAL'
    exporting
    name = p_fdir
    tables
    file_tbl = it_filedir.
    List of files are contained within table it_filedir
    loop at it_filedir.
    write: / it_filedir-NAME.
    endloop.
    Regards,
    Omkaram.

  • Is it possible to select all files within a directory (and not the folders/subfolders)?

    For instance, in my iTunes directory, I would like to select all of the music files without selecting the other olders (artist name, album name). Going through with Shift+click and command+click will take an eternity. If I just highlight everything and hit "open", it will open ALL of the folders as well as opening the actual files. I want to skip the folders if possible with a mass selection.

    Well, its gonna be an expensive comparison since there is no non-arbitrary way to iterate through the files, but try:
    String f1, f2;  // the comparing files
    //get a primary list of files to iterate through
    Process p = Runtime.getRuntime.exec("ls");  // if in Linux
    BufferedReader pri =
        new BufferedReader(
        new InputStreamReader(
        p.getInputStream()));
    while((f1 = pri.readLine()) != null){    // for each file...
        Process q = Runtime.getRuntime.exec("ls");  // get all file names
        BufferedReader sec =
            new BufferedReader(
            new InputStreamReader(
            q.getInputStream()));
        while((f2 = sec.readLine()) != null){   // and for each of these
            if(!f1.equals(f2))  // as long as it's not the same file
                DO_COMPARISON(new File(f1), new File(f2));   // compare them
    }

  • JFileChooser - Select All Files in the Directory

    Hi all. I am currently using JFileChooser and I need a functionality that will let the user choose a directory and then automatically select all the files that exists in that directory. I have tried looking around for references, but no luck so far. I hope someone can help. Thanks in advance.

    This is what I use frequently in my applications :
    * Requests the loading of all Images
    * in a directory.
    private void loadImageDirectory() {
      //create a FileFilter so the user only sees directories     
      javax.swing.filechooser.FileFilter dirfilter=new javax.swing.filechooser.FileFilter() {
        public boolean accept(File f) {
          if(f==null)
            return false;
          if(!f.isDirectory())
            return false;
          return true;
        public String getDescription() {
          return "Directories only";
      //now create the filechooser     
      JFileChooser jfc=new JFileChooser();
      jfc.setDialogTitle("Select a directory");
      jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      //remove the standard FileFilters (otherwise shows files too     
      jfc.resetChoosableFileFilters();
      //Set a FileFilter for directories only
      jfc.addChoosableFileFilter(dirfilter);
      int result=jfc.showOpenDialog(this);
      jfc_image_dir=jfc.getCurrentDirectory();
      if(result==JFileChooser.APPROVE_OPTION) {
        //here i call a method that does something with the directory     
        iv.addDirectory(jfc.getSelectedFile());
    }This always worked for me ??
    You might want to try??

  • Selecting all files from JFilechooser and renaming them??

    dear all
    i am working on a application that selects the jpeg,jpg,jpe files form the jfilechooser with an additonal botton rename which calls the rename method and the selected file is renamed.
    i have been succssful in mselecting one file and renaming it.but the problem is with...
    1) Selection of multiple files and sending their names and parent directories getParent(); is not working with taht....should i use arrays to store that .....but how when i have enabled multiple selection already.
    2)SEcond problem is to refersh the contents of JFileChooser after i have renamed it.iwant that it shopuld be refreshed automatically just after renaming has been done.
    help is always appreciated..
    regards
    s m sharma (trainee s/w/ engg)

    hi everybody
    i have done it myself.......it was not too tough that u didnot responed...anyway thanks..
    regards
    s m sharmna

  • Reading Files from client directory folder using servlets or struts.

    HI All,
    Could you please help me out int the below query.
    I want read all files from paricular directory folder from the client machine in web application. I am able to do it from my local machine. but when I am try to do it from some other machine I am not able to get the file list.
    It is very urgent ..please hep me ASAP.

    It should be problem with the file permissions in your client machine ???Hardly.
    @OP: a servlet executes at the server. It doesn't haved any access whatsoever to the client machine.

  • FTP Adapter to read multiple files from a directory. Not through polling.

    Dear Friends,
    I would like to know is it possible to configure the FTP adapter in Oracle BPEL 10.1.3.4 to read multiple files (different names, same structure) from a given directory. I do not want the BPEL to do a polling. Instead when I submit the BPEL process it should read all files from the directory.
    I was looking at the option of Synchronous read but I am not able to specify wild card in the file name field. I do not know the file names at the time of reading.
    Thanks for your help!

    Hi,
    While you read the file, you can configure an adapter property in 'Receive'. This will store the filename, this filename can be used for sync read as the input parameter.
    1. Create a message type variable called 'fileheader'. This should be of type Inboundheader_msg (whatever relevant Receive activity).
    2. This variable will contain three parts - filename, FTPhost, FTPPort
    3. Copy this fileheader to 'Syncheader'.
    4. syncheader can be passed as an adapter proerty during sync read of the file.
    During Receive and Invoke, you need to navigate to 'Adapter' tab to choose the created message type variable.
    Let me know if you have further questions.
    regards,
    Rev

  • Get all files from Directory

    Hi All,
    My requirment is to get releted files from Local Directory.
    For Example Path is "D/Data/"
    in this path there is files like
    abc123_de.txt
    abc123_en.txt
    xyz123_de.txt
    abc123_pt.txt
    xyz123_en.txt
    pqr123_en.txt
    bcg234_en.txt
    sjd467_en.txt
    Now i want to use only files which are strart from abc123 and use their data.
    From which FM i can do it or how can i do this?
    Thanks,
    Mahipalsinh

    Dear Mahipalsinh,
    I have got the same requirement some days back, i think there is no FM for your requirement. so what i did, i have get all the files using below FM and Concatenate the ABC.
    Please use the Below FM, because if the file name is above that 50 character that time always it gives the full file name. Please check, if u used the other one for getting the Files.
       CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'
         EXPORTING
           iv_dir_name            = lv_dir_name
         TABLES
           dir_list               = lt_file_name
         EXCEPTIONS
           invalid_eps_subdir     = 1
           sapgparam_failed       = 2
           build_directory_failed = 3
           no_authorization       = 4
           read_directory_failed  = 5
           too_many_read_errors   = 6
           empty_directory_list   = 7
           OTHERS                 = 8.
       IF sy-subrc <> 0.
    * Implement suitable error handling here
       ENDIF.
    For reading Specific Files.
    CONCATENATE 'AP' lv_internal_date INTO lv_filename.
             LOOP AT  lt_file_name INTO ls_file_name.
               lv_index = sy-tabix.
               IF ls_file_name-name CS lv_filename.
              " PUT YOUR LOGIC
              endif.
         endloop.
    Thanks,
    Nishant

  • I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I

    I previously had PS CS5 Trial installed but removed it using both Control Panel Programs and deleting all files from the CS5 directory on Program Files.  I then installed a purchased product from Adobe disc using the serial number on the case.  But when I try to launch it, I get a screen headed Photoshop CS5 Extended Trial.  It asks for the serial number and says that my trial has expired.  It rejects the serial number from the Adobe case saying "This Serial Number is not valid for this product".  It thinks that I still have the expired Trial Version installed.  How do I convince it (the program) that the Trial Version is long gone and the currently installed product was installed with a valid and accepted serial number????

    Let me know how it goes. Go into your Adobe account and register your serial number asap.
    https://www.adobe.com/account/my-products-services.html
    That way, should you lose it or you need support, it is on record that it's yours and you can fetch your s/n it from anywhere.
    There are too may sad stories here, where people forgot and the box is buried or lost.
    Gene

  • To pick files from multiple directory in FILE ADAPTER

    Hi all,
    Is their any settings or adapter configuration parameters to be used  to pick  the files from multiple directory .

    Hi,
    You can only specify one directory on the communication channel. The advance selection allows the selection of different files within this directory.
    Therefore you will need a communication channel for each directory you wish to pull files from.
    (Just looked at the blog and see it is possible after all - I'm on the wrong SP)
    Kind regards
    Colin.
    Message was edited by:
            Colin Bickell

  • Auto selection of file from folder during uploading??

    Hi all friends,
    Iam facing with one problem I am developing one uploading software for that i have used swing and servlet.Now my problem is i want to give auto selection of file from one folder means user just copy the files from any computer on network and paste it in predefind folder.And when they click on upload button it should start uploading of file one by one and after completion of uploading it move that file into another folder one by one.Now my software doing it perfectly but if user copy and paste any file in that predifined folder from network computer during uploading then they have to click upload button again after completion of first queue of files(for example if user first copy 10 files and start uploading and inbetween uploading of that 10 files if user copy another 10 files from network computer then they have to click on upload button again after completion of uploading of first 10 files).But my user requirement is they want to click on upload button once only at the time of starting my application and my application automatically select the file one by one from folder and send it to destination.Means if they copy the file from network machine inbetween uploading or any other user from network send file in that folder then my application should select those file automatically and start uploading means they don't want to click on upload button again.Can any one plz guide how I can slove this problem.Below r my codes:-
    Upload.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    try {
    suspendflag=true;
    Resume.setEnabled(false);
    Suspend.setEnabled(false);
    dest=frame.m_txtURL.getText();
    File ff=new File("d:\\DTMS\\Upload");
    File[] files = ff.listFiles();
    fileList = new Vector();
    if(files == null)
    textArea.append("There is no file");
    return;
    else
    for (int j = 0 ; j< files.length ; j++)
    fileList.add(files[j]);
    java.util.Collections.sort(fileList, new FileComp());//sorting by size
    new Thread(new Runnable() {
    public void run(){
    for (int k = 0; k < fileList.size(); k++)//loop for queue {
    File fname = (File)fileList.get(k);
    String str=fname.getName();
    log("Destination:" +" "+ dest);
    log("Uploading Progress\nPlease Wait....");
    result=doPost(fname,dest);//method for read file & send to servlet
    String str2="Transfer apparently failed.";
    String str3=result;
    if(str2.equals(str3)){
    Error(result);
    else if(suspendflag==true){
    File newfile =new File("d:\\DTMS\\Archives\\"+str);
    fname.renameTo(newfile);
    log("File" +" "+ str+" "+"Upload Completed !");
    else if(suspendflag==false){
    Error("** Transfer Suspended**");
    }).start();
    }catch(Exception exp)
    Error("Error : " + exp.toString());
    Regards
    Bikash

    Hi Chandan,
                        All the multiselection files are stored in it_tab( i:e file_table in method). you need to loop the every record to upload the data for selected files. please check the code Below...
    DATA: file_str1 type string.
    data: it_tab TYPE STANDARD TABLE OF file_table,
           wa_tab TYPE file_table,
           lw_file LIKE LINE OF it_tab,
           gd_subrc TYPE i.
    SELECTION-SCREEN begin of block blk with frame title text-100.
    SELECTION-SCREEN SKIP 2.
    parameters : p_file like rlgrap-filename .
    SELECTION-SCREEN end of block blk.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
    CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
    window_title = 'Select only Text File'
    default_filename = '.azt'
    multiselection = 'X'
    CHANGING
    file_table = it_tab
    rc = gd_subrc.
    *READ TABLE it_tab INTO lw_file INDEX 1.
    *p_file = lw_file-FILENAME.
    Start-of-Selection.
    loop at it_tab INTO wa_tab.
       file_str1 = wa_tab-FILENAME.
    CALL FUNCTION 'GUI_UPLOAD'
       EXPORTING
         filename                      = file_str1
    *    filename                      = '\\10.10.1.92\Volume_1\_projekte\Zeiterfassung-SAP\test.azt'
       tables
         data_tab                      = it_string
    IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDLOOP.

  • Java Program to copy file from one directory to another failing

    Hello All,
    Oracle Applications 12.1.3
    RDBMS: 11.2.0.30
    SQL*Plus: 10.1.0.5.0
    Java beginner here so help is much appreciated.  I'm have some java code that I'm using to copy a file from one directory to another in an Oracle Applications Server.  I notice that when moving to a new instnace I started to get file not found errors.  I think it's because of the directory.  My question is, does the directory in which I trying to pick up the file have to be a DBA_DIRECTORY, or a UTL_FILE directory in order for the java to find the file and move it?
    Here is my code...
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "COPY_FILE_JVS" AS
    import java.io.*;
    public class COPY_FILE_JVC{
      public static void copy(String SourceFile, String DestDir) {
        File source = new File(SourceFile);
        File dest = new File(DestDir);
        File cpDestFile = null;
        try {
          if (dest.isDirectory()) {
              if(source.isFile()) {
                System.out.println("File name = " + source.getName());
                System.out.println("File name dest = " + dest.getPath() );
                System.out.println("File name cpDestFile = " + dest.getPath() + File.separator + source.getName());
                cpDestFile = new File(dest.getPath() + File.separator + source.getName());
              else {
                System.out.println("Directory or File Not Found");
                return;
          BufferedInputStream  br = new BufferedInputStream (new FileInputStream (source));
          BufferedOutputStream  bw = new BufferedOutputStream (new FileOutputStream (cpDestFile));
          int read = 0;
          while((read = br.read()) != -1) {
            //System.out.println((char)read);
            bw.write(read);
          br.close();
          bw.close();
        catch (FileNotFoundException e) {
        e.printStackTrace();
        catch (IOException e) {
        e.printStackTrace();

    I get these messages when calling the java from SQL Plus as follows...
    serveroutput on size 100000;
    dbms_java.set_output(1000000);
    MY_PKG.CopyFile('/home/my_user/set_env.sh','/interface/home'); (this is call to oracle pl/sql package which calls the java.)
    PL/SQL procedure successfully completed.
    Directory or File Not Found
    PL/SQL procedure successfully completed.
    If I change the directory from /home/my_user/ to any directory that is defined in DBA_DIRECTORIES or is a UTL_FILE directory to program works.  Is it perhaps because the java is in a PL/SQL package as seen below?  The PL/SQL program runs as the APPS user and I have issued the following the command grant JAVASYSPRIV to APPS.
    Here is the PL/SQL Package....
    CREATE OR REPLACE PACKAGE BOLINF.MY_PKG AUTHID CURRENT_USER AS
    CopyFile(p_SourceFile IN VARCHAR2, p_DestDir IN VARCHAR2);
    +++++++++++++++++++++++++++++
    CREATE OR REPLACE PACKAGE BODY BOLINF.MY_PKG  is
    CopyFile(p_SourceFile IN VARCHAR2, p_DestDir IN VARCHAR2)
    AS LANGUAGE JAVA NAME 'COPY_FILE_JVC.copy(java.lang.String, java.lang.String)';

  • Open file from a directory that is not web accessible?

    Subject says it all really, I'd like users to be able to download files from a directory that is otherwise not accessible by the browser. There is a way to do this is PHP, the readfile() function. Is there something equivalent in Java?
    Thanks!

    You can do that with a Servlet and a shot of java.io API.
    Here's an example: [http://balusc.blogspot.com/2007/07/fileservlet.html].

  • CRASH IN L9...select 10 files from Audio Bin to a track set to flex...

    CRASH IN L9
    ...select 10 files at once from Audio Bin (short sfx files) to a track set to flex (monophonic flex mode)......when prompt appears select: "all files on same track"
    CRASH!
    SvK

    You're welcome,
    you were clear before ...no it doesn't crash ..i tried it again on a different/new audio track with monophonic flex enabled b4 dragging the audio clips(short audio drum tracks) on that track
    maybe because I'm on 10.5.7?
    A
    Message was edited by: immo

Maybe you are looking for

  • Some .mpkg files don't open in Installer!  10.8.2

    I purchased a huge music software and sound library of 79GB (Komplete 8 namely) The file contains 12 part .iso files and each of them shows either .pkg and .mpkg after mounting. The .pkg files and .mpkg files opens fine, except for 1 of them.... whic

  • Add an event to weekly calendar view on ios7

    the new ios7 on iphone 5 does not seem to allow you to add an event on calendar when in weekly view; in fact, it seems you have to be on monthly view and do a 'search' function just to get on to weekly view (the most useful view); this seems absurd -

  • Lenovo W530 no longer boots since updating past 3.7.1

    Hi, I've been suffering from this for a while and I finally thought I should get around to asking the collective wisdom of the forums.  I use rEFInd to boot my laptop and everything has been working well until I updated to 3.7.3.  The next time I reb

  • File Adapter Issue - Don't wont polling

    I am trying to create a bpel process that takes user input and then as I continue the flow thru the process I get to a point where I want to read a file using the adapter, but I want the flow to invoke the partner link and not the adapter polling for

  • Services procurement - Pricing Access sequence error for Custom fields

    Hi Experts, We have created 3 custom fields in KOMP structure. Which is required to create condition tables, access sequence. We have successfully created condition tables with the 3 fields along with the standard fields. While creating access sequen