Listing a special type of files in a subDirectory

hi all,
i have a directory where there are some other subdirectories inside it .
each one of these sub directories contains 2 files: an xml file and a PNG file .
can i obtain a list of all the xml files only in all subdirectories ??
if any body knows please try to reply and show me how can this be done...
thanks in advance.
regards,
D.Roth.

Quick and dirty, and if you only need the file names, you could just use String for your Lists, instead of File references.
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class Test  {
     public static void main(String[] argv) throws IOException
          List<File> javaFiles = new ArrayList<File>();
          File topDir = new File("c:\\Testing");
          if(topDir.isDirectory())
               javaFiles = getFiles(topDir);
          System.out.printf("Found %d xml files is directory %s and its sub-directories",javaFiles.size(), topDir.getName() );
          for(File f : javaFiles)
               System.out.println(f.getPath());
     private static List<File> getFiles(File dir)
          List<File> fileList = new ArrayList<File>();
          File [] files = dir.listFiles();
          for(int i = 0; i < files.length; i++)
               if(files.isDirectory())
                    fileList.addAll(getFiles(files[i]));
               else if(files[i].getName().endsWith(".xml"))
                    fileList.add(files[i]);
          return fileList;
Of course, if you are that new, you might want to back up some and acutally learn java before doing stuff like this. Not that it is that complicated, but you need the basics first. Use this code as is at your own risk.
~Tim

Similar Messages

  • Any code available to get mime-type for file?

    Hi,
    at this link http://www.utoronto.ca/ian/books/html4ed/appb/mimetype.html you can find a huge listing of content-types for files. What I'd like to know is, if there's any code available for getting the right mime-type for a given file-extension. E.g given a filename "Document.doc" returns mime-type "application/msword".
    Thanks in advance,
    Tom

    U can use the isMimeType() method to compare various types.
    Eg. isMimeType("text/plain") or isMimeType("multipart/*") etc.

  • How to add list of multiple file types to file type of file dialog box in LabVIEW

    How to add list of multiple file types to file type of file dialog box in LabVIEW?
    In file dialog box there is option to add only one file type,in the list,not by seperating commas,
    regards,
    Naresh.N

    Write the file types in pattern Input string, separated by a semicolon ;
    For example:  *.vi;*.doc;*.jpeg;*.xls
    This should return the set of files with matching extensions
    Message Edited by devchander on 09-10-2008 08:02 AM
    Message Edited by devchander on 09-10-2008 08:03 AM

  • How to copy Sales Quotaton prices to Price List or Special Prices

    We frequently use Sales Quotation to communicate deal price offers to customers.  Once these prices are approved, we have to re-type these prices into applicable price lists or special prices. 
    We are looking for a way to copy these deal prices from Sales Quotation (by Business Partner) over to the applicable price list and special prices?
    Please assist?
    Jaco de Villiers

    I was told by my Implementation Partner that it is possible to import and update price list by using the Import function that is available in SBO.  To do this:
    1. From your sales quotation with the agreed prices - export to excel.
    2. Change the format to list: Product code, Price list to update, New price, Currency
    3. Save the file as tab delimited text
    4. Import into SBO using the Administration, Data Import/Export, Data Import, Import from Excel option.
    5. Choose Item type to import
    6. In the B line, choose Price List Code, the list updates to show only the fields relevant to price list updates
    7. Press OK and follow rest of instructions to complete the import.
    I found the above to be simple, repeatable and reliable enough to solve my initial question.

  • Change Log needed at price list and special prices

    Tracking changes made to the price list and special prices by BP is a valuable control function missing that needs to be included in future.

    I was told by my Implementation Partner that it is possible to import and update price list by using the Import function that is available in SBO.  To do this:
    1. From your sales quotation with the agreed prices - export to excel.
    2. Change the format to list: Product code, Price list to update, New price, Currency
    3. Save the file as tab delimited text
    4. Import into SBO using the Administration, Data Import/Export, Data Import, Import from Excel option.
    5. Choose Item type to import
    6. In the B line, choose Price List Code, the list updates to show only the fields relevant to price list updates
    7. Press OK and follow rest of instructions to complete the import.
    I found the above to be simple, repeatable and reliable enough to solve my initial question.

  • I can't open the attachment to a mail. I must open it i FileApp. but it says that there no App installed that open this type of file. What can I do? I've got iPad 2, version 4.3.3 (8J2) My age: 69 and not so good at computers.

    I can't open the attachment to a mail. When I'm trying to open it in FileApp, I get the answer: "FileApp doesn't recognise
    this file type.Would you like to try to open in.....
         another App
         as text file
         cancel
    When I open it it in another App I get the answer:"there are no application installed on your device that can open
    this type of file.
    When  I open it as a text file, it's loading and loading.....forever?
    What shall I do?
    PS I'm 70 and not good at computers

    Hello Mats in Sweden!
    I'm from Austria, not so far away! The file that you've received seems to be a Windows Media File and you may need a special software for your iPad to be able to open it. I've found something HERE.
    If you open this link on your iPad it should take you to the App Store, resp. open it. The price for this app is 1,59 €.
    Greets from Vienna,
    Bärbel

  • Getting all types of files with the help of get_file_name function

    hi all,
    i am using Forms [32 Bit] Version 6.0.8.24.1 (Production).
    i have used get_file_name function to the file name of all type of files
    but i am able to get only the folders when i tried like below
    :FILE_NAME := GET_FILE_NAME(NULL,NULL,NULL,'Choose a Directory',OPEN_FILE,FALSE);my requirement to get all types of files on the window(user will selects whichever way he wants)
    Can i acheive it through get_file_name or i have to go for any alternative to get the file list, so that user can select by browsing the folders.
    Please help.
    Thanks..

    hi,
    in my code the select file was set to false(so showing only the directories) now i have set it to 'true'. its showing the files now.
    with the help of my above shown code i can get the full path of the file.
    is there any way to get only the file name?(other than the last occurance of '/' logic or that is only the way?)
    Please help.
    Thanks..

  • I cannot save pictures from facebook to "my Pictures" files on my hard drive. There is no place to indicate the type of file, such as jpg etc.

    I have been copying a picture & pasting it on my AOL email & saving photos from Facebook from email . Also, I cannot watch videos posted by my friends on Facebook.
    Firefox works fast on scrolling thru Facebook but I haven't found it to be that helpful for simple things I want to do.
    Thanks for any help you can provide.

    Hi perric,
    On the first issue about pictures.
    * You can set Firefox to ask you where to save the file rather than always using the Downloads folder. This article describes how to set that: [[Startup, home page and download settings]].
    * When you say "there is no place to indicate the type of file, such as jpg etc." is the problem that Facebook isn't including that in the file name and you need to add it? If you could explain this part a bit more.
    * Another way to save pictures is to use the Page Info dialog. While on the page with the images, you can use either:<br><br>* right-click and choose View Page Info > Media<br>* Alt+t (open the classic Tools menu) > Page Info > Media<br><br>As you scroll down the list, you can preview and use the Save As button to save those "hard to get" images.
    On the second issue about videos.
    * Do you see a gray space indicating that you need a plugin? Or does the video not play when you click it? Please explain what you're experiencing in a little more detail.
    * In case you do not have the Flash player plugin for Firefox, you can get it here: http://get.adobe.com/flashplayer/ (make sure to uncheck any unwanted extras that Adobe might offer). If you do the download from IE, you won't get the right version. In that case, use this link to choose the non-IE plugin: http://get.adobe.com/flashplayer/otherversions/
    Hope that helps a bit.

  • "Could not complete your request because Photoshop does not recognize this type of file."

    I am using the latest version of Photoshop CC. When I attempt to open a recent .psd file listed in the Open Recent list, I get the message "Could not complete your request because Photoshop does not recognize this type of file." I can use the open command to open these files with no problem. The files are not damaged or missing the .psd extension and open normally except when using the Open Recent menu. OS is Mac 10.8.5. Thanks for any clues as to a fix.

    As weid as it may sound: simply don't use "Open recent...". Use Bridge to manage, find and start them in PS.

  • Unable to save ANY types of files in Elements 5.0

    Today I was working with Elements, creating a photomanipulation. This involved several layers, including a background of a beach, a horse, and some text. I've done this before with this exact same program on this exact same computer and not had too many problems. But not today.
    Today when I try to save my creation, in ANY format, I get this message:
    Could not save as
    "C:\Users\User\...\Untitled-1.jpg" because the file is already in use or was left open.
    GAHH!!!! Well of COURSE the stupid file is open, I'm working ON IT and trying to save my work!!! If I try to close the file, I get the standard question:
    Save changes to the Adobe Photoshop Elements document "Untitled-1" before closing?
    to which if I say yes, I get the same old crap:
    Could not save as
    "C:\Users\User\...\Untitled-1.jpg" because the file is already in use or was left open.
    Now if I select save as *PSD or *PDD, *SOMETIMES* it acts like it has saved my work, (Instead of just saying it can't) but when I look for what I saved, all I find are a bunch of crap files that can't be opened. Example:
    Cannot open 'C:\Users]User\Pictures\Photo Manips\~ps2AA0.tmp' because it is the wrong type of file.
    Please note that I never actually chose to save ANY files called ~ps2aa0.tmp at any point in this process.
    So I am stuck in a vicious cycle where before everything was working just fine. And it's not just editing photos or doing manipulations. I can take a brand new blank canvas, scribble a line on it with a paintbrush, and I am completely and totally unable to save even the simplest thing in ANY format whatsoever.
    I tried uninstalling Elements and reinstalling it and that did absolutely nothing, except cause me to lose all the special effect brushes I spent hours downloading. And when I started it back up, I was right where I was before, it even had the same custom color preloaded on the palette, as if it did not truly uninstall AT ALL. (Just the special brushes were missing, thanks for nothing!)
    My computer is maybe 8 months old now, a nice Hewlitt Packard with Vista. I specifically bought this computer so I could do more things with my art and more photos, and the first thing I loaded on it was the Bamboo tablet by Wacom, which came with Photoshop Elements 5.0 free. I've been using it ever since with hardly a problem and now today, I can't save the simplest little thing, and it is really aggravating me to death.
    ANY light that anyone could shed on this would be most appreciated. I'm sure it's something extremely stupid, like I found the secret invisible "do not save anything ever again" button and somehow managed to press it. Whatever it is, I can not for the life of me figure out how to make it work like it's SUPPOSED to work. Somebody please help me before I go stark raving mad.

    Further note: I have uninstalled this stupid program now THREE different times, including using a registry cleaner, which then deleted my DVD drive, thankyouverymuch. And even after I got the DVD drive back so I could reinstall the program, it was like I'd never uninstalled it (with the exception of the custom brushes still being missing) right down to the canvas size and paint color I had been using when all this started.
    So uninstalling it does nothing, resetting preferences does nothing... I can not save my work, period. I've been fighting with this for about 8 hours and I am so frustrated I could just throttle someone with my bare hands for putting me through this crap.
    For a product that came bundled with a $200 graphics tablet, it sure isn't worth a damn. Anybody got any ideas? I'm at my wits' end here.

  • How to list the top 10 largest files in the current working directory ?

    How can I list the top 10 largest files in the current working directory in Solaris ?

    execute below....to get the large files in order.. change the <FS>
    find /<FS> -type f -size +1024 -ls | awk '{print $11, $7}' | sort -rn +1 | awk '{print $1, $2/1024/1024 "MB"}' | /bin/more

  • When I try to convert my .pdf to Word, I get a sidebar that has fields for: the name of my pdf file, the type of file I want to convert to (In my case, Word), and a button that says "Convert".  My problem is that the "convert to" field isn't active.  I ca

    When I try to convert my .pdf to Word, I get a sidebar that has fields for: the name of my pdf file, the type of file I want to convert to (In my case, Word), and a button that says "Convert".  My problem is that the "convert to" field isn't active.  I can see the words "Microsoft Word" in pale gray, but when I click on the field, nothing happens.

    You have posted in the wrong forum.  Try posting in the forum for the product you are trying to use.
    Here is a link to a page that has links to all Adobe forums... use the drop down list to see all.
    Forum links page:
    https://forums.adobe.com/welcome

  • Sync error with Workspace "Data in this list references content type "", which is no longer in the list schema"

    Dear,
    I saved a document library containing folders and files as a template to use it as a template when I created a document library.  It contains a lot of folders and files.
    When I tried the document library to sync with workspace it gives an error "Data in this list references content type "", which is no longer in the list schema"
    I checked with this error and I found out that it has issue with onenote file, but my library does not contain any onenote file. 
    I wonder if there is any issue regarding the number of folders to sync at a time because when I tried to sync with document library similar to the big library but lesser folders and files. 
    Thanks

    This is caused by certain OneNote files.  I've filed a support ticket on this.  See my
    post on possible workarounds.  You might view the entire library in windows explorer or flatten the folder structure in a view to confirm that there are not any OneNote related files.
    Corey Roth blog: www.dotnetmafia.com twitter:
    @coreyroth

  • I mistakenly saved a download, and checked the "always do this for thid type of file" now I cannot open a file without saving it first, because it does not take me to that same dialog box.

    When you open a file from an email, you get a dialog box Open or Save this file. I wanted to save a particular file, so I clicked Save. The problem is, I had already clicked on "do this every time for files like this" so now it won't give me the dialog box back for when I just want to open a file, not save it. I have searched Options, to no avail.

    '''''"always do this for thid type of file"''''' means exactly what it says: '''<u>always</u>''' .
    Go to Tools > Options > Applications, locate and click on the Content Type for the item, change Action to "Always ask". This will cause a dialog to open giving you a choice of opening with an appropriate plugin for Firefox or saving the item to your hard drive. See:
    *http://support.mozilla.com/en-US/kb/Managing+file+types
    *http://kb.mozillazine.org/File_types_and_download_actions
    '''Other issues needing your attention'''
    The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post. You can also see your plugins from the Firefox menu, Tools > Add-ons > Plugins.<br />
    <br />
    *Adobe PDF Plug-In For Firefox and Netscape "9.4.1"
    **'''''Security update version 9.4.2 released on 2011-02-08'''''
    **Info on version 10 (Reader X)"
    ***New Adobe Reader X (version 10) with Protected Mode was released 2010-11-19
    ***See: http://www.securityweek.com/adobe-releases-acrobat-reader-x-protected-mode
    *Shockwave Flash 10.1 r102
    **'''''Security update version 10.2.152.26 released on 2011-02-08'''''
    *Next Generation Java Plug-in 1.6.0_23 for Mozilla browsers
    **'''''Security update version 1.6.0_24 released on 2011-02-10'''''
    #'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
    #*'''Note: plugin check page does not have information on all plugin versions'''
    #'''Update Adobe Reader (PDF plugin):'''
    #*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
    #**Open the Adobe Reader program from your Programs list
    #**Click Help > Check for Updates
    #**Follow the prompts for updating
    #**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
    #*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
    #**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
    #**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
    #**Click "Save to File"; save to your Desktop (so you can find it)
    #**After download completes, close Firefox
    #**Click the installer you just downloaded and allow the install to continue
    #***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
    #**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
    #***Choose your OS
    #***Choose the latest #.x version (example 9.x, for version 9)
    #***Choose the highest number version listed
    #****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
    #***Choose your language
    #***Download the file, SAVE it to your hard drive, when complete, close Firefox, click on the installer you just downloaded and let it install.
    #***Windows: choose the .exe file; Mac: choose the .dmg file
    #*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
    #**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
    #**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
    #*After the installation, start Firefox and check your version again.
    #'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
    #*Download and SAVE to your Desktop so you can find the installer later
    #*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
    #*After download is complete, exit Firefox
    #*Click on the installer you just downloaded and install
    #**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
    #*Start Firefox and check your version again or test the installation by going back to the download link below
    #*'''Download and information''': http://www.adobe.com/software/flash/about/
    #**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
    #**Use IE to go to the above site to update the IE ActiveX
    #*'''Download Manual installers'''.
    #**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
    #**Note separate links for:
    #***Plugin for Firefox and most other browsers
    #***ActiveX for IE
    #'''Update the [[Java]] plugin''' to the latest version.
    #*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
    #**'''''Be sure to <u>un-check the Yahoo Toolbar</u> option during the install if you do not want it installed.
    #*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
    #* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
    #* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org
    #*Java Test: http://www.java.com/en/download/help/testvm.xml

  • List of Special Characters in SAP

    Hello All,
    Can anyone help me with a list of special characters that can be accepted by SAP ?
    Issue: Ariba(An Interface) has various special characters and they send files to GIF(An Interface). GIF takes those special characters and then generates idocs.. but when sending data to sap.. sap is not able to recognise some characters ..
    Appreciate your help.. Thanks.
    Regards,
    Pranay

    SAP reads "!" as space since R2 days.

Maybe you are looking for