Files in folder

hey..I'm new in programming and I want to know how can I get a list of files from a folder and put it in a comboBox and then select the file that I want...Thank you very much

String[] fileList = file.list();http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
see file chooser
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
//This example lists the files and subdirectories in a directory. To list all descendant files and subdirectories under a directory,
File dir = new File("directoryName");
    String[] children = dir.list();
    if (children == null) {
        // Either dir does not exist or is not a directory
    } else {
        for (int i=0; i<children.length; i++) {
            // Get filename of file or directory
            String filename = children;
// It is also possible to filter the list of returned files.
// This example does not return any files that start with `.'.
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return !name.startsWith(".");
children = dir.list(filter);
// The list of files can also be retrieved as File objects
File[] files = dir.listFiles();
// This filter only returns directories
FileFilter fileFilter = new FileFilter() {
public boolean accept(File file) {
return file.isDirectory();
files = dir.listFiles(fileFilter);
hth
Message was edited by:
java_2006

Similar Messages

  • Hi,delete file from folder?

    hi,i am deleting file from folder as follwos
    <%@ page import="java.io.File" %>
    <%
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\xyz.txt");
    myFile.delete();
    %>
    i am sucessfuly deleted file from above path.
    if i use follwing code i unable to delete my file, can one help,
    how to do it,
    <%@ page import="java.io.File" %>
    <%
    String fname="xyz.txt";
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\'"+fname+"'");
    myFile.delete();
    %>
    thanks
    pullareddy

    i think if above doesn't work try this it should work
    change this line
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\'"+fname+"'");
    to this
    File myFile = new File("D:\\jakarta-tomcat-4.1.18\\webapps\\ROOT\\upload_files\\"+fname);

  • Delete file from folder only (not from list)

    Hi all,
    I've searched a lot and didn't succeed so far, that's why I need your help. In a cloud context, I'm actually creating and uploading files (pdf and/or xml files) "on the go" to sharepoint folders via the SOAP API and this is perfectly working. But
    in a cloud context, I also need to decomission services which is translated into deleting files into Sharepoint.
    That's where it became complicated, because according to the API we cannot delete files if they are not part of a list structure, which is not my case. Is that true ?
    The only info I have when trying to delete a file via the SOAP Api is : its name, its folder, and the endpoint where the folder is. So my question remains simple I guess : is this possible ? If so, how to (a link to the SOAP body would be usefull)
    Thanks a lot
    Regards
    Baptiste

    Hi,
    According to your post, my understanding is that you want to delete file from folder.
    In SharePoint 2010, It is recommended to use Client Object Model to achieve it, the following code snippet for your reference:
    string siteURL = "http://siteurl";
    ClientContext context = new ClientContext(siteURL);
    //specific user
    NetworkCredential credentials = new NetworkCredential("username", "password", "domain");
    context.Credentials = credentials;
    Web web = context.Web;
    context.Load(web);
    context.ExecuteQuery();
    string relativeUrl =web.ServerRelativeUrl +"/DocumentLibraryName/FolderName/FileName";
    File file = web.GetFileByServerRelativeUrl(relativeUrl);
    context.Load(file);
    file.DeleteObject();
    context.ExecuteQuery();
    If you still want to use SOAP API, we can use the UpdateListItems method under Lists web service to achieve it.
    http://www.dhirendrayadav.com/2010/06/delete-list-items-using-web-service.html
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/61466984-1844-48a1-8c1e-1c59a0f9876a/move-and-delete-files-remotely-using-sharepoint-web-services-?forum=sharepointdevelopmentlegacy
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • [Solved] Error : The file or folder path /Probl?me 1 does not exist

    Hello,
    I encountered this error
    The file or folder <path>/Probl?me 2 does not exist
    while I was trying to open a directory already extracted from a zip file containing directories with special characters. In this case, it is a "è" that was misinterpreted as a "?".
    I searched the forums and on google, the solutions proposed do not work for me. Although, I have to deal with these files written in french, I would like to have my locale in english (US), with a system wide support for special characters.
    Attempt 1: Adding the option : iocharset=utf8 into the fstab, like this :
    fstab :
    # /etc/fstab: static file system information
    # <file system> <dir> <type> <options> <dump> <pass>
    none /dev/pts devpts defaults 0 0
    none /dev/shm tmpfs defaults 0 0
    /dev/cdrom /media/cd auto ro,user,noauto,unhide 0 0
    /dev/dvd /media/dvd auto ro,user,noauto,unhide 0 0
    /dev/fd0 /media/fl auto user,noauto 0 0
    /dev/disk/by-uuid/24ba75ac-e52d-40eb-a599-83b394b500b2 /boot ext2 defaults 0 2
    /dev/disk/by-uuid/c797f409-00bc-479a-b4d6-ab49943f644b / ext4 defaults 0 1
    /dev/disk/by-uuid/668427a8-5f51-42bd-a316-fc7984bf5f4f /var ext4 defaults 0 2
    /dev/sda7 swap swap defaults 0 0
    /dev/disk/by-uuid/417cd1b7-8f06-414b-84d5-e8714d9646ab /home ext4 defaults 0 2
    /dev/disk/by-uuid/ef9aa00e-0515-4d7b-aa23-8096e787250d /usr ext4 defaults 0 2
    /dev/disk/by-uuid/17d401b7-2fc7-4d9f-8e17-657d86926d2e /tmp ext4 defaults,iocharset=utf8 0 0 <<<<<<<<<<<<<<
    /dev/disk/by-uuid/71e543b6-e06c-4b0e-b1e3-3b491ff1fefe /var/cache/pacman/repos ext4 defaults 0 2
    #/dev/sda12 /mnt/archive ext4 defaults 0 2
    #.host:/ /mnt/hgfs vmhgfs defaults 0 0
    This solution does not work, because after adding iocharset=utf8, in front or after a "defaults", after a reboot, while mounting the filesystem, there is the following error message:
    Mounting Locale Filesystem :
    mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
    missing codepage or helper program, or other error
    In some cases useful info is found in syslog - try
    dmesg | tail or so
    $ dmesg | tail
    phy0: Selected rate control algorithm 'iwl-agn-rs'
    EXT4-fs (sda5): re-mounted. Opts: (null)
    EXT4-fs (sda5): re-mounted. Opts: (null)
    EXT4-fs (sda6): mounted filesystem with ordered data mode. Opts: (null)
    EXT4-fs (sda8): mounted filesystem with ordered data mode. Opts: (null)
    EXT4-fs (sda9): mounted filesystem with ordered data mode. Opts: (null)
    EXT4-fs (sda10): Unrecognized mount option "iocharset=utf8" or missing value <<<<<<<<<<<<<<
    EXT4-fs (sda11): mounted filesystem with ordered data mode. Opts: (null)
    Adding 2104476k swap on /dev/sda7. Priority:-1 extents:1 across:2104476k
    tg3 0000:07:00.0: irq 44 for MSI/MSI-X
    Attempt 2: Changing all the locale features in KDE and in /etc/rc.conf as well.
    $ vim /etc/rc.conf
    LOCALE="fr_CA.utf8"
    HARDWARECLOCK=""
    TIMEZONE="America/Montreal"
    KEYMAP="us"
    CONSOLEFONT=
    CONSOLEMAP=
    USECOLOR="yes"
    It is complicated to remove these directories. I had to use the inum to get precisely these directories before removing them.
    $ ls -il
    total 8
    1577566 drwxr-xr-x 2 [username] [username] 4096 28 jan 07:09 Probl?me 1
    1577573 drwxr-xr-x 2 [username] [username] 4096 28 jan 07:09 Probl?me 2
    $ find . -inum 1577566 -exec rm -i {} \;
    rm: impossible de supprimer « ./Probl\212me 1 »: est un dossier
    Note that the hypothetical character 'è' is represented has a '\212', a 'È' if seen as a extended ASCII character.
    These directories cannot be deleted this way :
    $ rm -r Problème\ 1
    rm: cannot remove `Problème 1': No such file or directory
    or
    $ rm -r ProblÈme\ 1
    rm: cannot remove `ProblÈme 1': No such file or directory
    What should I do to be make the operating system recognize those special character, and interpret them correctly ?
    Last edited by ramboman (2011-01-29 21:45:50)

    I found a working solution, but better solution are also welcome
    I had to have fr_CA not only in utf8 but also in iso88591. I had to modify the /etc/rc.conf this way :
    LOCALE="fr_CA" <<<<<<<<<<<<<<
    HARDWARECLOCK=""
    TIMEZONE="America/Montreal"
    KEYMAP="us"
    CONSOLEFONT=
    CONSOLEMAP=
    USECOLOR="yes"
    To preserve the english US language system wide, I had to add the following line in the /etc/profile :
    # Allow french special character while in en_US
    export LANG=en_US
    The character misinterpreted by a "?" is now seen :
    as a "è" in dolphin
    as a "?" in the console
    It is now possible to access the folders.

  • Does simple file and folder sharing on an iMac work with OSX Server?

    Hi There
    I wonder if I should install OSX Server on an iMac wher several users work on the same files and folders.
    My question - before I do something I might regret:
    Does simple file and folder sharing on an iMac within several users really work with the help of OSX Server?
    All I want to be able to do:
    Admin creates a new folder1 and gives it read- and write access for user1 and user2.
    User1 creates a subfolder1 in folder1, and a document1 in subfolder1.
    User2 edits document1. Later Admin edits document1.
    All these simple editing of files and folders (and subfolders) within a main folder should be possible. This is not possible now.
    Is everything clear? I'm not a network specialist or something, I just want to give some co-workers access to some data on my computer without problems.

    So what you need are recursive permissions.
    I suggest you create a group and add user1 and user2 to that group. You can name that group whatever you want, but for now i will call it FSUsers
    Execute this in terminal. Replace FSUsers with your new group
    sudo chmod -R +a "FSUsers allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextat tr,writeextattr,readsecurity,file_inherit,directory_inherit" /Users/Shared/*
    Replace /Users/Shared with the location of your shared folder. Make sure you keep the /* at the end (this allows all subfolders and files to get the same permissions.
    If you need to add people to the share just add them to the FSUsers group, the FSUsers group should should also be allowed in the sharing preferences.

  • TS4153 few files and folder are not deleting from trash folder

    i am trying to delete all files and folders from the trash folder by clicking  empty securely, but its not deleteing the files anf folder. please suggest how to clean the trash folder by deleteing all the deleted files and folder.

    Securely deleting items in Trash writes Zeros over the data so that it is completely eradicated.
    This will take quit a long time depending on how much data you have in Trash.
    Unless there is data that needs to be rendered unrecoverable in the Trash, you could choose to just delete the files and folders with out the secure option.
    Once you have Emptied the Trash unsecurely you can always use disk utility to Securely Erase Free Space on the Drive.

  • Hi ! i am using mac air i download from app store IDESKTOP when i open it its delete all my file and folder on my mac, hi ! i am using mac air i download from app store IDESKTOP when i open it its delete all my file and folder on my mac

    hi ! i am using mac air i download from app store IDESKTOP when i open it its delete all my file and folder on my mac, hi ! i am using mac air i download from app store IDESKTOP when i open it its delete all my file and folder on my mac

    Here you can contact the developer.
    (Notice, I'm posting this line only once. Not 4 times. )

  • How do you delete [empty] a single file or folder from "Trash"?

    How do you delete [empty] a single file or folder from "Trash"?
    Can you "securely delete" just 1 item?

    A dangerous and incorrect shell command has been posted in this thread.
    NEVER empty the Trash in the shell (Terminal.) NEVER put anything in the Trash unless you intend to delete it immediately. If you do put something in the Trash and change your mind about deleting it, move it out or use the Put Back contextual menu item. Then empty the remaining items in the Trash as usual.

  • POWER QUERY Get External Data From File From Folder (Excel 2013)

    Hi,
    Beginner's question :
    What could be the use of the query on a folder : we just get a list of files with their path. What can we do with that?
    Thanks

    Hi,
    Do you want to combine data from multiple Excel Files in the same folder path into one table? If I understand correct, we can add a custom column to import the data.
    After we getting a list of files with their path, the Query Editor window will activate to show you a table containing a record for each file in the chosen directory. These will provide our function with the needed FilePath and FileName parameters. 
    Function sample: File name([Folder path],[Field name]
    For more detailed steps, please see the article:
    http://datapigtechnologies.com/blog/index.php/using-power-query-to-combine-data-from-multiple-excel-files-into-one-table/
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft does not guarantee the accuracy of this information.
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Print PDF file from folder using SSIS

    Is there a way in SSIS to print pdf file from folder?
    ANy help much appreciated.

    One method is calling Adobe Acrobat Reader exe from Execute Process Task within SSIS passing the document path as the argument
    The command and arguments will look like this
    http://geekswithblogs.net/JeremyRamos/archive/2013/10/22/print-ssrs-report--pdf-from-sql-server-agent-or.aspx
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Read contineously file from folder

    HI
    I have 1000 of files and I want read files from folder automatic. Each file ends with
    if $BATCH_FILE==true
    define $END,false
    else
    power off
    define $END,true
    if 1 text file is finish then it should load another file automatically

    Hi kalu,
    don't know what you're trying to do:
    - you have a "path" control but you don't use it for ListFolder...
    - you get an array of filenames from ListFolder, but you don't use that data later on...
    - you are using "OpenFile"/CloseFile to get a file path (in the event) and later on you use that path to read data from...
    Your original question doesn't has anything in common with those things you do now...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • To find total number of files inside folder

    Hai,
       In knowledge management is there any option to find total number of files inside folder...
        I also want to see the recently uploaded and modified documents in a seperate iview...
        Iam using NW2004s SP8..
        Very urgent..
        Waiting for a positive reply..
        Thanks&regards,
         Kiruthika.S

    Hi Kiruthika,
    1. You only need the configarchive if you don't want create all the KM configuration objects mentioned in the guide manually. So, just create the objects mentioned there and you don't need the configarchive
    Also, the scenario works also on 2004s.
    2. Please check this thread on how to show the total number of files inside a folder:
    https://forums.sdn.sap.com/thread.jspa?threadID=19610
    3. It would be nice if you would consider rewarding the time people like Saravanan spend to investigate and answer your question by assigning points via the colored stars.
    Best regards,
    Robert

  • Want to open Kodak Photo CD files (.PCD) in Photoshop CS5.  In CS4 i copied file "Photo CD.8BI"  from an older version into the File Format folder.  This does not work with CS5.  Any fix?

    I have several old Kodak Photo CD with PCD image files.  I am now using Photoshop CS5.  Some years ago while using Photoshop CS4 I copied a file:  "Photo CD.8BI" from an older, CS2, version to the Plug-ins/File Format folder of CS4.  This does not appear to work with CS5.  Any fix?

    It can be made to work, but you have to run the 32 bit version of Photoshop CS5, and as I recall there's an additional DLL called pcdlib32.dll that's needed from the old installation.
    See also:  Open Kodak PhotoCD files in PS CS5 - is it possible? (Win XP)
    -Noel

  • File or Folder does not exist

    I'm having a wierd problem with a png image which generates an error in my script.
    I'm building a UI using the group constructor, here is the line code I'm using to load the image:
    myImg:Image{text:'',image:'(image_folder)/image.png', alignment:['left','top']}
    The script runs with one image but not another one which is also a png of the same dimensions, bit depth etc. For some reason I get the 'file or folder does not exist' error message. If I replace the image with a known good one the script works.
    I've re-generated the image a dozen times. Still no joy.
    I'm not a total noob, though I infrequently write scripts and am completely prepared to learn I've made totally maverick error.
    Any thoughts?

    myImg:Image{text:'',image:'(image_folder)/image.png', alignment:['left','top']}
    I'm assuming that "(image_folder)" is a placeholder or variable and you are concatinating for the file path to the image? When checking file paths for images or what not, I usually try...
    alert(File.decode(File.openDialog()));
    ...to verify that my path is correct. Sometimes there's a extra slash or something I am missing.

  • Part of Photoshop isn't functioning.  Under adjustments, when HDR toning is clicked on I get a code:  Error 48: File or folder does not exist.  Line:11  - $.evalFile(g_StackScriptFolderPath   "StackSupport.jsx");  How can it be fixed?

    The phone company was here working on something while I was gone.  They sat down at my computer (iMac) and since then HDR toning doesn't work.  Get the code:   Error 48: File or folder does not exist.    Line: 11     ->  $.evalFile(g_StacScriptFolderPatch + "StackSupport.jsx");   How can this be fixed?   

    Go to //Applications/Adobe Photoshop [Version]/Presets/ Scripts/Stack Scripts Only/ and see if StackSupport.jsx is there. If it is not, uninstall and reinstall Photoshop to have it added back in. If it is there, first try recreating the Photoshop Preferences (hold down Command+Option+Shift while launching Photoshop).

  • HDR Toning Error 48: File or Folder Does Not Exist

    After migrating to a new computer HDR Toning is no longer available.
    I get a pop-up: Error 48: File or Folder Does Not Exist
                             Line 11  -> $. evalFile(g_StackScriptFolderPath + "StackSupport.jsx");
    What's the fix for this, if anyone knows?
    Thanks.

    Go to //Applications/Adobe Photoshop [Version]/Presets/ Scripts/Stack Scripts Only/ and see if StackSupport.jsx is there. If it is not, uninstall and reinstall Photoshop to have it added back in. If it is there, first try recreating the Photoshop Preferences (hold down Command+Option+Shift while launching Photoshop).

Maybe you are looking for

  • Can we assign jython variable value into ODI variable?

    Hi Team, We are trying to save jython variable value into ODI variable so that ODI variable can use in later steps. we are facing failure regards same. Please suggest us so that we can use ODI variable value in later steps. Thanks Ankush.

  • Outlook 2013 crashed when user sending email from Adobe Writer xi pro ver 11.0.07

    I ask Adobe, but they are signaling to Outlook problem PC-HP, Windows 8.1 Pro X64 connected to Windows 2008 R2 DC Adobe Acrobat Pro ver 11,x When user trying to send email from Adobe direct, Outlook 2013 Pro is crashing The only way to send email is

  • Aligning footnote numbers to the left

    Hello, I am currently in the process of designing the thesis of my sister. The text - imported from word - contains several footnotes. The problem is when I placed the word document the footnote reference numbers were automatically aligned to the rig

  • Not all V.I.s in Logic will play??

    My Midi Keyboard is an 88 key M-Audio Key Controller, and I'm using a MOTU 8 pre interface. I can get most of the virtual instruments to play through my MIDI controller, but certain ones - specificaly the organs just won't play. Anybody have any clue

  • OPA Siebel Error - Entity instance does not exist

    Hi We have installed Siebel OPA connector in our environment and want to have a rule base based on below entities Opportunity(S_OPTY) and Opportunity Product(S_REVN) Created new Entities : dealProduct (1 to M) to Global Added attributes in dealProduc