Get file name from folder

Hi all,
how to find a .txt file in a particular folder. My text file comes with
following name <fixed_name>.<mmddyy><hhmmss>, e.g., fn_fnprod.102806015605
so how to get this file name. nd also tell me if there are multiple files
then how to retrieve the oldest one first and so on....
Thanks & Regards
Gaurav

it's fine but how to know which is older file b'cpz
this file comes every day with new date & time. so
what if there a multiple file. nd i have proceed
oldest first.
pls help asapget each file last modifed, using file.lastModified() method and compare which file you would be needing. =)

Similar Messages

  • Get File name from incoming IDoc

    HI All,
    I am in an IDOC to File scenario using Fcc. (R/3 --> XI --> 3rd party)
    I need to use the  idoc-number(EDI_DC40-Docnum) as my output file name. I planned using variable substitution but there it expects me to get the idoc number from payload which I do not have it in. (refer c ode below)
    As I understand, variable substitution can be used only on payload(the FINAL data set that we will be writing to the file).
    Can we use the data which is part of incoming IDOC and not part of payload(final data what we are writing to file).??
    Other idea was to map this IDOC no to a field in final file, but this field should not be written in the output file, so am confused about how to achieve this.
    E.g
    *Incoming Data*
    IDOC
      |_EDI_DC40
        |_DOCNUM
    Final data (Payload)
    Header
    Data
    Trailer
    As seen in my example above I do not have the IDOC no in the final data so how do I use the Idoc no as my filename? Apprecaite your help on same.
    Regards
    Shirin

    Hi
    You can use dynamic configuration to get the file name .
    Use Adapter Specific Message Attributes for the target Comm Chanel check the indicator for filename in the advanced tab of CC
    create a UDF with i/p as file name  i.e the Idocnum field and
    paste this code
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    //conf.removeAll();
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    //String filename= conf.get(key);
    conf.put(key, fileName);
    key= null;
    return fileName;
    PS: use cache as value in UDF
    ands assign the o/p of this UDF to a root node

  • Sharepoint 2010 -Script to get file name from Document Library

    Hi 
    can anybody send be script that works in "SharePoint 2010 management Shell" to get list of file names in document library.
    Thank

    See my updated answer. The double quotes need to be removed. Also note that you need to use $item.File.Name
    and not $item.Name to get the name of the files.
    Blog | SharePoint Learnings CodePlex Tools |
    Export Version History To Excel |
    Autocomplete Lookup Field

  • How to get file name from file adapter (Read Operation)

    Hi All,
    I am reading files from local location, in jca file i gave filename property =*.* ( which reads all files), and now I want to read the incoming file name inside bpel and I want to copy the file name to some variable. Is this possible?

    Yes, its possible.
    In your receive activity,set below property in its properties tab:
    <bpelx:property name="jca.file.FileName" variable="FileName"/>
    Before that make sure to create a variable "FileName" of string type.
    Whatever file your file adapter will read,its name will be stored in this variable.
    Hope this helps.
    Regards,
    Karan
    http://learn-oraclesoa.blogspot.com/

  • Need help getting files names from directory

    I have never done anything in php before and I'm struggling.
    In an attempt to search through potential document names in a directory, I've added the following code to a new php document:
    <?php
    if ($handle = opendir('.')) {
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                echo "$file\n";
        closedir($handle);
    ?>
    with no luck. When executed all I get is a blank screen. Any ideas why?
    End goal is to list the file names in the directory so that the user can choose to open desired document. Thanks!

    Click here and pick the option which best fits your situation.
    (93771)

  • Getting file name from a file path

    Hello
    I have got a String called filePath and it holds: "C:\Documents and Settings\paul\MyDocuments\nihtd.txt".
    What I want do is to have another String variable called fileName that will use the 'filePath' variable to return the name on the file (that been "nihtd.txt" for the example given) but it must work with any file path for any file type.
    Can anyone help? I have tried various ways but with no success.
    Many thanks
    Paul

    Hmm, I just ran across another distinction between doing this by creating a File object as opposed to doing this by analysing the String: performance.
    I always thought that creation of file objects is relatively cheap, since the Filesystem is not actually accessed when you create a new File instance. Apparently that is not true, at least not if you are on Windows and the file is on another server. Something like new File(\\server\share\file.txt) will create network traffic on Windows. So if you only meant to use the File class for parsing text, you might want to think again.
    I would be interested to know how the FileSystem class is implemented on different platforms. Do you know where I can read up on that?
    Cheers, HJK

  • File name from a path

    hi ,
    there is a path "c:\abc\abc\abc\abc\abc.doc", i have to get file name from it.
    but i had to write a dynamic code which can get the file name from any given path.

    Smoke me a kipper, I'll be back before breakfast.
    SQL> var extended_filepath varchar2(128)
    SQL> exec :extended_filepath := '/this/is/a/path/to/a/file.txt'
    PL/SQL procedure successfully completed.
    SQL> select instr(:extended_filepath, '/', -1)
      2  from dual
      3  /
    INSTR(:EXTENDED_FILEPATH,'/',-1)
                                  21
    SQL> select substr(:extended_filepath, instr(:extended_filepath, '/', -1) +1)
      2  from dual
      3  /
    SUBSTR(:EXTENDED_FILEPATH,INSTR(:EXTENDED_FILEPATH,'/',-1)+1)
    file.txt
    SQL> Cheers, APC

  • How to get the target file name from an URL?

    Hi there,
    I am trying to download data from an URL and save the content in a file that have the same name as the file on the server. In some way, what I want to do is pretty similar to what you can do when you do a right click on a link in Internet Explorer (or any other web browser) and choose "save target as".
    If the URL is a direct link to the file (for example: http://java.sun.com/images/e8_java_logo_red.jpg ), I do not have any problem:
    URL url = new URL("http://java.sun.com/images/e8_java_logo_red.jpg");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Everything is fine, the file name I get is "e8_java_logo_red.jpg", which is what I expect to get.
    However, if the URL is an indirect link to the file (for example: http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719 , which link to a file named JavaSetup6u18-rv.exe ), the similar code return AutoDL?BundleId=37719 as file name, when I would like to have JavaSetup6u18-rv.exe .
    URL url = new URL("http://javadl.sun.com/webapps/download/AutoDL?BundleId=37719");
    System.out.println("Opening connection to " + url + "...");
    // Copy resource to local file                   
    InputStream is = url.openStream();
    FileOutputStream fos=null;
    String fileName = null;
    StringTokenizer st=new StringTokenizer(url.getFile(), "/");
    while (st.hasMoreTokens())
                    fileName=st.nextToken();
    System.out.println("The file name will be: " + fileName);
    File localFile= new File(System.getProperty("user.dir"), fileName);
    fos = new FileOutputStream(localFile);
    try {
        byte[] buf = new byte[1024];
        int i = 0;
        while ((i = is.read(buf)) != -1) {
            fos.write(buf, 0, i);
    } catch (Throwable e) {
        e.printStackTrace();
    } finally {
        if (is != null)
            is.close();
        if (fos != null)
            fos.close();
    }Do you know how I can do that.
    Thanks for your help
    // JB
    Edited by: jb-from-sydney on Feb 9, 2010 10:37 PM

    Thanks for your answer.
    By following your idea, I found out that one of the header ( content-disposition ) can contain the name to be used if the file is downloaded. Here is the full code that allow you to download locally a file on the Internet:
          * Download locally a file from a given URL.
          * @param url - the url.
          * @param destinationFolder - The destination folder.
          * @return the file
          * @throws IOException Signals that an I/O exception has occurred.
         public static final File downloadFile(URL url, File destinationFolder) throws IOException {
              URLConnection urlC = url.openConnection();
              InputStream is = urlC.getInputStream();
              FileOutputStream fos = null;
              String fileName = getFileName(urlC);
              destinationFolder.mkdirs();
              File localFile = new File(destinationFolder, fileName);
              fos = new FileOutputStream(localFile);
              try {
                   byte[] buf = new byte[1024];
                   int i = 0;
                   while ((i = is.read(buf)) != -1) {
                        fos.write(buf, 0, i);
              } finally {
                   if (is != null)
                        is.close();
                   if (fos != null)
                        fos.close();
              return localFile;
          * Returns the file name associated to an url connection.<br />
          * The result is not a path but just a file name.
          * @param urlC - the url connection
          * @return the file name
          * @throws IOException Signals that an I/O exception has occurred.
         private static final String getFileName(URLConnection urlC) throws IOException {
              String fileName = null;
              String contentDisposition = urlC.getHeaderField("content-disposition");
              if (contentDisposition != null) {
                   fileName = extractFileNameFromContentDisposition(contentDisposition);
              // if the file name cannot be extracted from the content-disposition
              // header, using the url.getFilename() method
              if (fileName == null) {
                   StringTokenizer st = new StringTokenizer(urlC.getURL().getFile(), "/");
                   while (st.hasMoreTokens())
                        fileName = st.nextToken();
              return fileName;
          * Extract the file name from the content disposition header.
          * <p>
          * See <a
          * href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html">http:
          * //www.w3.org/Protocols/rfc2616/rfc2616-sec19.html</a> for detailled
          * information regarding the headers in HTML.
          * @param contentDisposition - the content-disposition header. Cannot be
          *            <code>null>/code>.
          * @return the file name, or <code>null</code> if the content-disposition
          *         header does not contain the filename attribute.
         private static final String extractFileNameFromContentDisposition(
                   String contentDisposition) {
              String[] attributes = contentDisposition.split(";");
              for (String a : attributes) {
                   if (a.toLowerCase().contains("filename")) {
                        // The attribute is the file name. The filename is between
                        // quotes.
                        return a.substring(a.indexOf('\"') + 1, a.lastIndexOf('\"'));
              // not found
              return null;
         }

  • How to get the file name from Oracle B2B 10g

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

    Hi My requirement is I am getting a CSV file from Trading partner, I am using oracle 10g b2b to translate the data.
    In my BPEL 10g I am using AQ adapter to get the message from IP_IN_QUEUE.
    Now I want to get the file name Eg: SampleFile.dat of the CSV file in my BPEL process.
    I tried using the b2b.filename property in the receive activity and it is not getting the file name.
    <sequence name="main">
        <receive name="Receive_Note" partnerLink="GetB2BNote"
                 portType="ns1:Dequeue_ptt" operation="Dequeue"
                 variable="Receive_Note_Dequeue_InputVariable"
                 createInstance="yes">
                 <bpelx:property name="b2b.fileName" variable="WriteFileName"/>
        </receive>
      </sequence>
    Can you help me to get the file name from Oracle b2b 10g ?
    Thanks,
    b2b user

  • Get file name and path from  adf inputFile

    Hi,
    I use adf's inputFile component. I need to get the file name and filePath. Does anyone knows how to do that?
    Thanks in advance

    You may bind the value to an UploadedFile object and get the name from this object.
    You may use a valueChangeListener backin bean method or a managed bean.
    Here the code i just write for something similar. Note that i'm not able to test it because of a bug in 10.1.3.1 with inputFile and web.xml parameters. I still waiting for the patch.
    public void uploadedFile(ValueChangeEvent valueChangeEvent) throws IOException,
    Exception {
    final int BUFFER = 2048;
    byte data[] = new byte[BUFFER];
    int currentByte;
    String fileName;
    UploadedFile uploadedFile =
    (UploadedFile)valueChangeEvent.getNewValue();
    if (uploadedFile != null) {
    String mimeType = uploadedFile.getContentType();
    if (mimeType == "application/x-zip-compressed") {
    // get the uploaded file as a zip file
    ZipFile zipFile = new ZipFile(uploadedFile.getFilename());
    // verify the zip archive contains only one entry
    if (zipFile.size() != 1) {
    FacesContext context =
    FacesContext.getCurrentInstance();
    ResourceBundle errorMessage =
    ResourceBundle.getBundle(context.getApplication().getMessageBundle());
    Exception ZipFileContentException =
    new Exception(errorMessage.getString("error.fileUpload.zipFileContent.moreThanOneEntry").replace("{0}",
    String.valueOf(zipFile.size())));
    throw ZipFileContentException;
    // get the entries in the zip file even it is only one
    Enumeration zipFileEntries = zipFile.entries();
    // Process each entry
    while (zipFileEntries.hasMoreElements()) {
    // grab a zip file entry
    ZipEntry entry =
    (ZipEntry)zipFileEntries.nextElement();
    // check the entry is not a directory
    if (entry.isDirectory()) {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.zipFileContent.isDirectoryInsteadFile"));
    throw ZipFileContentException;
    File destFile = new File(entry.getName());
    Magic magic = new Magic();
    // getMagicMatch accepts Files or byte[],
    // which is nice if you want to test streams
    MagicMatch match = magic.getMagicMatch(destFile, true);
    if (match.getMimeType() != "application/xml") {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.isNotXMLFile").replace("{0}",
    match.getMimeType()));
    throw ZipFileContentException;
    //TODO get the repository directory from classification-param.xml
    BufferedInputStream is =
    new BufferedInputStream(zipFile.getInputStream(entry));
    FileOutputStream fos = new FileOutputStream(destFile);
    BufferedOutputStream dest =
    new BufferedOutputStream(fos, BUFFER);
    // read and write until last byte is encountered
    while ((currentByte = is.read(data, 0, BUFFER)) !=
    -1) {
    dest.write(data, 0, currentByte);
    dest.flush();
    dest.close();
    is.close();
    zipFile.close();
    } else if (mimeType == "application/xml") {
    String currentEntry = uploadedFile.getFilename();
    File destFile = new File(currentEntry);
    BufferedInputStream is =
    new BufferedInputStream(uploadedFile.getInputStream());
    FileOutputStream fos = new FileOutputStream(destFile);
    BufferedOutputStream dest =
    new BufferedOutputStream(fos, BUFFER);
    // read and write until last byte is encountered
    while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
    dest.write(data, 0, currentByte);
    dest.flush();
    dest.close();
    is.close();
    } else {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.isNotXMLFile").replace("{0}",
    mimeType));
    throw ZipFileContentException;
    }

  • How to get IDL file name from CORBA IOR string

    hi, is it possible to get IDL file name from the IOR string? how?
    regards

    Hi,
    I don't think so.
    And if it was possible, which interface should be returned if
    the referenced object implements more than one?
    Regards.
    Karl

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Offline Folder can not chaange the letter of a file name from capital to lowercase

    Dear Expert,
    we deploy the offline folder to end users, there is a strange issue happened now, if user tries to change the letter of a file name from capital to lowercase, the system will show "You need permission to perform this aciton". But other actions
    are fine, like, create, delete, rename, etc.

    Hi,
    Please check if the offline folder is made available offline to end users. The Offline Files feature uses the client-side cache (CSC) database.  When the files are made available offline, the CSC database prevents users from changing the case of file
    names.
    For more detailed information, please refer to the article below:
    You cannot rename files by using different case when the files are made available offline in Windows Vista or in Windows 7
    http://support.microsoft.com/kb/953945/en-us
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Get Logical file name from Physical file name

    Hi everybody,
    Please how can i get Logical file name from Physical file name ?
    Thanks & Regards
    Hassan

    Hi,
    What i want is to get Logical file name from Physical file name, and not the opposite (get Physical file name from Logical file name).
    Thanks & Regards,
    Hassan

  • Need to get file name and directory back from file adapter - WRITE

    I am using the file adapter to write a file. I want to log the file name of the file we just created. Since we use a precise timestamp in the file name, I can't accurately guess.
    I have an invoke in my BPEL process to the file adapter. My first try was to assign the jca.file.FileName property to a variable, but it never comes back. I looked around and saw plenty of ways to SET the file name for a write and GET the file name for a read, but no GET file name for WRITE.
    Anyone have a solution?
    Thanks in advance!

    I think I got your point... You can tell FileAdapter the filename to write, but if you don't then FileAdapter can not tell you the filename that it wrote... I think it is pretty possible Oracle didn't implement the latter, as the write operation is probably asynchronous and the filename is calculated later on...
    If what you want is just log, you may achieve your requirement by increasing verbosity on Adapter logs... Have a look at the link bellow...
    http://docs.oracle.com/cd/E15586_01/integration.1111/e10226/ad_mon.htm#CJHHBBID
    Otherwise, the solution for you will be to calculate filename yourself, and that will be a little bit of reinventing the wheel... But at least you will know the filename...
    Cheers,
    Vlad

Maybe you are looking for

  • 500 Internal error observed while accessing a Static Web based course

    Hi Experts   When I try to start a static web-based course in portal, a 500 Internal server error comes up on the screen and the course not played at all.   Please suggest. Regards Shaily

  • Drag and drop in a report

    Drag & drop behaviour / event handling / double click behaviour: ·        If a document info record is dragged from the result ALV grid to a specific tree node, there should come up a decision popup, asking if the document should be inserted as BOD i

  • PHP and Apex

    I like PHP and I like Apex. Is there any chance to see an interaction between the two? I know that it is possible to link PHP with the Apache server which runs Apex but I am asking for the field addressing and exchanging the variables between PHP cod

  • Outlook Sync Issue "Intellisy​nc- Store ID not in current config"

    I recently bought the BB Curve for my personal phone/organizer and have installed the software.  I have been trying to sync my BB to my 2007 MS Outlook, but for some reason it won't (my Outlook is not associated with MS Exchange).  It goes through th

  • Rule based engine

    I know that this is not a strictly related xml matter. I would like to know if anyone can help me in finding a business rule based engine to be used inside a campaign management application