List of the Files in a Directory based on Filename filter

Hi,
Do any one has an idea about fileName filter Usage.
Ex: in UNIX: $ ls -l *.java gives the list of the java files in the directory.
To acheive this we FilenameFilter. please let me know if anyone has any idea about this.
Regard's
Kartheek

All of the answers to these questions, and more, are a mouse-click away. You can't develop a Java application without referring to the core Java API javadoc:
http://java.sun.com/j2se/1.4.2/docs/api/index.html
Your current task is to find the following classes and methods, and make sure you understand what they do:
java.io.File :: list(FilenameFilter filter)
java.io.FilenameFilter :: accept(File dir, String name)
java.lang.String :: endsWith(String s)
Once you get done with those, I'm sure there's a lot more you'll want to look up.
Good luck.

Similar Messages

  • Drop the files into different directories based on the filename

    Hi,
    I had a reqiuirement based on the file name, i should drop the files in to different directories.
    I can get the filename through variable substitution in receiver file communication channel, now i want to drop the file into different folders based on conditions.
    suppose, if the file name is DDDX234
    i should do substring of filename0+(4), if the value is L then i should drop in X directory
    suppose, if the file name is DDDY234
    i should do substring of filename0+(4), if the value is L then i should drop in Y directory.
    How can i drop the file into differnent directories based on filename.
    Thanks
    Srinivas

    Thanks Michal,
    I mapped the directory and filename to the target header in the mapping
    Filename --> UDF --> Header(target)
    and in the receiver channel checked the ASMA and given * in the filename and directory name.
    But in runtime iam getting the error as
    Attempt to process file failed with com.sap.aii.adapter.file.configuration.DynamicConfigurationException: The Adapter Message Property 'FileName' was configured as mandatory element, but there is no 'DynamicConfiguration' element in the XI Message header
    MY UDF is
    public String Directory(String a,Container container){
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key  = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "FileName");
    DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/File", "Directory");
    String FileName = conf.get(key);
    FileName = a;
    conf.put(key, FileName);
    %%%based on filename the directory should change
    String Directory = conf.get(key1);
    Directory = "/SAPInterface/XI/PPD/DHX/out";
    conf.put(key1, Directory);
    return "";
    Help me in correcting this error.
    Thanks
    Srinivas

  • 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.

  • Plsql utility to traverse directory to list all the files

    Hi All?
    Anybody know of anyway to traverse a directory and list the files under that directory?
    Thanks
    Rgds
    Ung

    Do you want the directory and files on the server or
    the client?On the server.

  • How to list all the files in a FTP site?

    I am now using LV7.1 and trying to list all the files (with file name, file size and modified date) on both a local drive and a remote FTP site. I can manage to do on a local drive, but is it possible to list the files on a FTP site?
    Thanks,
    Cola

    Listing files on a local drive and listing the contents of an ftp site are two different things. Access to an ftp site uses a totally different protocol. Off the top of my head, you have a few options:
    Use a third-party tool that can map an ftp drive to a local drive letter. WebDrive is one such client. Note: I'm assuming Windows here.
    Use the Intenet Toolkit.
    Use the LabVIEW TCP/IP functions to write up your own ftp client to connect to the server, change to the desired directory, and send the command to list the contents, which you can parse and spit out as a nice little array of filenames. Check the LabVIEW examples, as I believe there's some examples on this. You should also search this board for "ftp client", as this has been brought up before, and samples have been posted.

  • I have a task, that is i want to retrive the details from active directory based on name and i want show that details into grid view.

    Hi All,
    I have a task, that is i want to retrive the details from active directory based on name and i want show that details into grid view.
    Can any one help how to start.
    Thanks in advance!

    Hi AnilKarthik,
    You can get user details by name using DirectoryService namespace. Then you can create a DataTable to restore the information and then bind to the SharePoint GridView.
    Here are some deatiled code demos for your reference:
    how to get userdetails from Active Directory based on username using asp.net:
    http://www.aspdotnet-suresh.com/2011/03/how-to-get-userdetails-from-active.html
    How to get User Data from the Active Directory:
    http://www.codeproject.com/Articles/6778/How-to-get-User-Data-from-the-Active-Directory
    Using SPGridView to bound to list data in SharePoint:
    http://nishantrana.me/2009/03/23/using-spgridview-to-bound-to-list-data-in-sharepoint/
    Best Regards
    Zhengyu Guo
    TechNet Community Support

  • Selecting all the files in a directory

    How would i select all the files in a directory, write the info of the files into a new file, and after the end of each file, make a New Line?

    hi zymus,
    check this code u will get the solution for ur problem..
    import java.io.*;
    public class files {
    public static void main(String[] args) {
    File f = new File("c://");// specify ur directory name here
    String[] n = f.list();
    System.out.println("ALL FILES.....");
                   if (n != null)
                             System.out.println("length = " + n.length);
    for (int i = 0; i < n.length; i++) { System.out.println("i = " + n[i]); }
                                  String[] n2 = f.list(new myJavaFileFilter());
                                  System.out.println("ALL JAVA FILES.....");
                                  if (n2 != null)
                                       System.out.println("length = " + n2.length);
    for (int i = 0; i < n2.length; i++)
         System.out.println("the files are::::::::: " + n2);
    class myJavaFileFilter implements FilenameFilter
    public boolean accept(File dir, String name)
         if (name.indexOf(".pdf") > 0)// give the file extension what u want
         return true;
    return false;

  • How can I get a file to copy all of the files in a directory except itself and the source of the copy function will be the directory the final program is in?

    How can I get a file to copy all of the files in a directory except itself and the source of the copy function will be the directory the final program is in? This application must be in Lab View 8.

    you mean something like this (see below)?
    Now you may have to implement code to check if the destination folder exists and to create it, etc.  But if you use the Front Panel Control to select the destination folder, it should be okay.
    Not the best implementation, mind you but you'll get the idea..
    Message Edited by JoeLabView on 04-18-2007 03:43 PM
    Attachments:
    copy folder contents.PNG ‏10 KB

  • Setting the UNIX file permissions after writing the file to a directory

    Hi Experts,
    Can we set the UNIX file permissions after writing the file to a directory using Receiver File Adpater in SAP PI 7.1 ?
    Thanks in Advance.
    Regards,
    Jyoti

    Hi
    you can use the option "Run Operatiing system Command after File Processing" in the file adapter.
    Thanks
    Rinku Gangwani

  • I purchased a album and only the first part of each song plays, even though the entire length is listed  in the file properities. Any Ideas?

    I purchased a album and only the first part of each song plays, even though the entire length is listed  in the file properities. Any Ideas?

    Assuming you are in a region where you are allowed to redownload your past purchases, delete the current copies from your iTunes library and then download again from your purchased history. If the problem persists, or that facility is not available in your region, contact the iTunes Store support staff through the report a problem links in your account history.
    tt2

  • Name of the file in a directory

    There is a file in a directory say C:\abcd
    I want to find the name of the file in that directory.
    There is only one file in that directory
    How to proceed with this

    Sarma,
    That was a little abrupt and rude of you. Oracle_Friend was only asking if anyone knew of a way to detect the existence of a file in a directory, not exactly asking the world of us. And for all you know he probably has already searched in documentation, but probably isn't quite sure what to look for.
    Remember : The manual has every damn thing that you want. We can only help you when you are stuck somewhere after having treid many options.a) sometimes people don't know what options to try so how can they have tried many options before posting on here.
    b) The manual doesn't have every damn thing that you want. I want a lot of money and some lunch cos I'm getting hungry, but it doesn't have that. On a serious note though, the manuals do miss things and can't possibly cater for everybody's business requirements.
    Chill out man, and help rather than hinder.

  • Moving the files from one directory to another.

    It seems that this would be simple but I am not able to do it easily. I just want to move files from one directory to another directory. I tried the file class renameTo as in the following...
    File fFrom = new File("C:\\uhin\\batch\\outgoing");
    File fTo = new File("C:\\uhin\\batch\\outgoing\\back");
    fFrom.renameTo(fTo);
    but this doesn't seem to work. I have tried deleting the directory and then recreating it but this doesn't seem to work as in.
    fTo.delete();
    fTo.mkdir();
    any ideas ?
    thanks
    kris.

    That code you have there tries to rename the directory from C:\uhin\batch\outgoing to C:\uhin\batch\outgoing\back. I'm not sure if you can rename directories in general, but even if you can that particular renaming wouldn't work.
    However you didn't want to rename the directory in any case. You need to use a File method called listFiles (if I recall correctly... check the API documentation) which returns an array of File objects, representing all the files in that directory. Then loop through that array, and for each File in it, (1) create a new File object with the new name, and (2) call renameTo() to rename the file.

  • Upload all the files in a directory

    Hi,
    I have searched in forum for a solution to my problem (Upload all the files contained in a certain directory) but all I've found is solutions to upload a single file using the bean JspSmartUpload. I had myself used this bean to uploads files to an server, but files choosed by the user with the <input type="file">. What I'm wanting know is different and I can't find a solution to it. I've tried to change the jspsmartupload to do this but I'm having no success..
    Anyone can help?
    Thanks in advance,
    Nuno.

    I don't believe there's any support in pure html forms to accomplish this.
    The File class has a listFiles() method, that will return an array of all the files in a directory. As this code must run on the client machine, you will need to write an applet to accomplish this. You will also have to worry about the security sandbox, and sign your applet.
    To get each file to the server you will need to create a URL object, openConnection on it, set up a multipart form POST to it, and transfer the files, one by one.

  • Script to create directory based on current file name and then save the file in that directory

    Hi all,
    I have a need save all my projects in a directory using the name of the main image I am working on.
    Manually these are the steps I used:
    Save As.
    Copy ( press command-c <== the filename is highlighted by default so all I have to do is )
    New Folder ( press the new folder button. Brings up a dialog box)
    Paste ( press command-v. <== Pastes the file name into the "New Folder" dialog box.)
    Save ( press thre save button. Saves the files into the new folder )
    Save As.
    Change format to JPG
    Save
    Change image quality to 12
    I want to assign these actions to a key
    Recording these steps and playing them back does not give me the results I need, snce the original name is hard-coded in the actionlist that was recorded
    What should I be doing instead ?
    Thanks in advance !

    You don’t mention which format the original file is (and figuring that and its current settings out seems too much of a hassle to me) so this would only save the jpgs into the folder (and create one if it does not exist).
    If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS4 or /Applications/Utilities/Adobe Utilities-CS5/ExtendScript Toolkit CS5) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.
    After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action, (in CS4 and CS5) be used in a Configurator-Panel or started from ExtendScript Toolkit directly.
    // saves jpg into folder of file’s name next to file;
    // be advised: this  overwrites existing jpgs of the same name without prompting;
    // thanks to xbytor;
    // 2012, use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    var thedoc = app.activeDocument;
    // getting the name and location;
    var docName = thedoc.name;
    if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
    else {var basename = docName};
    // getting the location, if unsaved save to desktop;
    try {var docPath = thedoc.path}
    catch (e) {var docPath = "~/Desktop"};
    // create folder if it does not exist;
    var folderString = docPath+"/"+basename;
    if (Folder(folderString).exists == false) {new Folder(folderString).create()};
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 12;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    //save jpg as a copy:
    thedoc.saveAs((new File(folderString+"/"+basename+".jpg")),jpegOptions,true);

  • Making a list of all the files in a directory

    I have a simple little plotting program that I would like to give the following functionality:
    I'd like the user to be able to select a directory (folder) containing several text files (as well as possibly other files and/or folders). The app should identify which files in the selected directory are text files and then do something with the information in each of those files. I have no problems allowing the user to select one file at a time, but I can't figure out how to have my cocoa app sort through a directory and pull out the files it needs.
    If someone could at least point me to an example somewhere on the dev site that would be awesome. I've searched for "working with files", "working with directories", "file wrappers", etc. and can't seem to find a way to do this!

    Thank you! I don't know why I couldn't find this when searching the help documentation.

Maybe you are looking for

  • My drop down options menu is transparent. Why is this happening & how do I fix it?

    Ever since I've upgraded to Firefox 19 from 18 none of my drop down menus work, they're all completely transparent as you can see in the following screen shot: http://i.imgur.com/PvKyZ6K.png It's this way in every field in which drop down options app

  • Upgraded to iTunes 7.7 and can't sample music

    I upgraded my iTunes to 7.7 and now I cannot sample the music. I double click and the speaker icon displays however nothing plays. I did insert a cd and played it on media player and the cd played okay. I have no idea what is going on with this new i

  • MEMASSCONTRACT not working properly

    Dear MM Experts, I want to carryout a mass change on contract line items using transaction MEMASSCONTRACT. I followed all the necessary steps in enterting the contract number/line item, new values and saving the new values in MEMASSCONTRACT. The syst

  • Temperature controlled cooling for K7N2G - making a cheap and quiet sy

    Hi! My CPU and IGP fan speed is temperature controlled. The two fans in my PSU are very quiet. Beside these i have two fans blowing air into the cabinet and two fans blowing air out. At the moment I have the option to let them stay turned off, to giv

  • Keynote won't export to quicktime get a green screen.

    Been using Macs for a long time but am new to Keynote '09. When trying to export a slideshow in Quicktime to use in iMovie, I get window with a progress bar and a green screen and a Quicktime file that plays back a green screen! I have searched the f