Finding filenames in a specefik directory

Hi There
I would like to find all files in a specifik windows directory, an I would like to sort them on the base of the timestamp in the "Modified" colom in the windows Explorer.
Can this be done and if so them how?
Whit my debest respect to all
Regards
Tolstrup

Member xraynaud has the right idea however I believe he meant to use the File class's lastModified method. In any event his implementation (subtracting the two longs) looses precision and will subsequently not return a properly sorted array. See attached sample working code that also uses a FileFilter to only return files (excluding directories) from the specified directory.
import java.io.*;
import java.util.*;
public class SortByDate
public static void main(String args[])
  File[] files = new File("c:/").listFiles(new FileFilter() {
   public boolean accept(File pathname) {
    return !pathname.isDirectory();
  Arrays.sort(files, new Comparator() {
   public int compare(Object obj1, Object obj2) {
    long l1 = ((File) obj1).lastModified();
    long l2 = ((File) obj2).lastModified();
    return l1 > l2 ? 1 : (l1 < l2 ? -1 : 0);
  for (int i = 0; i < files.length; i++)
   System.out.println(files[i] + "\t" + new Date(files.lastModified()));

Similar Messages

  • TS3991 I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this?

    I am a landlord and I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this? as an example 37 31 1 and when i type this nothing is showing.

    I am a landlord and I organazied my contacts by the address of my tenants. I just joined to Icloud and I am not able to find my tenants in the directory in the computer at all. I could search when I am using my phone but they do not show at first.how can correct this? as an example 37 31 1 and when i type this nothing is showing.

  • Issue related finding a file in a directory

    Hi
    I am trying to find a file from a directory and print it on screen using only first half of the file name.
    like I have files you_are_best.pdf,you_are_geneious.pdf, we_are_best.pdf. Now I need to find the pdf from the directory having name you_are.
    can any one help me in solving this issue.

    Sukant_at wrote:
    Hi
    I am trying to find a file from a directory and print it on screen using only first half of the file name.
    like I have files you_are_best.pdf,you_are_geneious.pdf, we_are_best.pdf. Now I need to find the pdf from the directory having name you_are.
    can any one help me in solving this issue.Read this.

  • Find filenames in directory

    Is there some way to parse a specific directory and get the names of the files in that directory? I have a folder named FILES that will contain *.xls files. My intent is to have the program parse the FILES directory and display all of the file names in a JOptionPane.showInputDialog() method. I know you can use JFileChooser to select files but I do not want the user to have that freedom. I only want to show the files of a specific directory.
    If you have an ideas, I would really appreciate your comment! Thanks!

    Ugh, I should think before I post... I searched Google for an hour reading different sites. So I decide to come here and post.. but I never thought to search the forums beforehand. Thanks, sorry for wasting your time! =\

  • How to find out who deleted the directory in Unix

    Hi Experts,
    In my system some body tampered the directories, and more over some body deleted the bin directory under the /usr/sap/trans in Unix operating system. now i am checking to find out who deleted and for the more logs.
    i am unable to find out the user name and deleted directory logs..i know its completely related to the unix level but mean time i am searching for the same.
    Any ideas and clues will be heighly appreciated.
    -Srini

    To know the OS would have been helpful
    First ask the people around you if anybody did it, maybe he is man enough to admit...
    Try to find out who logged at the time when the directory was deleted.
    - check the OS syslog (/var/adm/syslog/syslog.log for hp-ux, /var/log/messages for linux)
    - try the last commando to get a list of who logged on when
    - check the command histories of the sidadm, root user, use the history command, or the h alias
    - check if there are scripts running, which regularly delete files
    As the trans directory might be NFS mounted to other servers, you might need to do the checks there too.
    Best regards, Michael

  • How do I find where the Apache home directory is?

    I am working with a server on which someone else installed Apache. In fact, they have both Apache 1.3 and Apache 2.0 on it. Only Apache 2.0 is active. I don't know what they used to install it or where Apache came from. The people who installed it cannot be reached.
    How do I find out which directory is Apache_home?
    At first I tried looking for files and directory names that I thought would show up in the Apache_home directory tree:
    Tried 'locate apache' in root, and got dozens of directories or files with the word "apache" in them.
    Tried 'locate httpd.conf', and got two listings (etc/httpd/conf/httpd.conf and usr/lib/opcenter/fastcgi/httpd.conf). One might be for each of the Apache versions?.. but which is which?? Are either of them under the "apache_home" directory??
    Tried 'locate libexec' (one of the directories Im need to find) and got user/libexec and user/local/libexec.
    Is there a configuration file or something that has a statement like "$Apache2.0_home=XXX/XXX/XX" that would tell me where it is??
    Thanks in advance.

    No, Apache _home is a sort of the base directory for
    the apache installation. According to some literature I read today, this directory should've been /usr/local/apache/bin/, but that's not where I found my apache install (cygwin, I let the installer handle all the defaults).
    Mine was under /usr/sbin/, and to be correct I was looking for the httpd.exe (cygwin specific) file.
    I'd suggest running a find / -name (file you are looking for) to locate your resources.

  • Class can't find anothe class in same directory.

    Hi
    I'm using javac and appletviewer and I keep getting this strange reaction.
    I've got a couple of classes, one extends the other. ie:
    class a
    class b extends a
    Now when I compile b it says it cannot find class a. Both of these java files are in the same directory. Class a compiles fine on its own but I can't compil b.
    Also, when compiling a with the statement:
    package c
    as the first statement and then trying to run the compiled class in the appletviewer, I get the following error:
    java.lang.NoClassDefFoundError: a (wrong name: c/a)
    The Applet window comes up but with applet not initialised.
    Can anyone help with this? I purposely didn't put up the code because I figured it would be unnecessary.
    Thanks
    allan

    Yep, that solved the compiling error. Thanks.
    Any ideas about the applet viewer problem? Or where I can look for an answer?
    allan

  • Cannot find file bookDB.jar at directory ejb.

    Could anyone help me!!
    I wanna try the sample of J2EE EJB. But I met a problem. According to the BookStore3`s tutorial, the file bookDB.jar ought be under the directory ejb/, but I cannot find it at there.

    I am sorry. I could not read the tutorial clearly. The file bookDB.jar is built at sample Bookstore2, only is used at sample Bookstore3.

  • How to find multiple entries in the Directory

    Hi,
    my directory contains lot of multiple entires and I want to find out is there a easier method by a script or command to find out all the mutiple entries in the directory.
    Thanks!!
    Message was edited by:
    Sun_One@TCS
    Message was edited by:
    Sun_One@TCS

    Are you talking about entries that have been renamed because of a Replication Naming conflict (like the entry was added on 2 masters at the same time) ?
    If so, please check the Administration Guide, Replication section.
    <http://docs.sun.com/app/docs/doc/819-0995/6n3cq3av8?a=view#gdquf>
    If you were talking about something else, please be more explicit. Directory Server does not allow you to create multiple entries with the same name. DNs are unique.
    Regards,
    Ludovic

  • Find the File name from directory

    Hi Experts,
    My Scenario is:
    Pick the file from the Directory, Based on the file name, get the Q information from R/3 system and place the file into MQ.
    My Question is : How can I get the file name?, any one please guide me..
    Thanks for your help,
    Thanks,
    SR

    HI SR
    You need to enable the Adapter-Specific Message Attributes
    enable the FileName under this. Enabling this will allow to have this parameter as XI header
    You can check this value is generated or not using SXMB_MONI -> Inbound message -> SOAP header  -> Dynamic Configuration.
    This will be captured under http://sap.com/xi/XI/System/File name =  FIleNameu201D
    Now code given by Anand above will allow you to use this FileName in mapping. Based on this you can check R/3 system for relevant file.
    Hope this make you confortable with filename concept
    Thanks
    Gaurav

  • Unable to find user list in Active Directory Authenticator

    Hi all,
    I am using weblogic 10.3 and want to configure ActiveDirectory Authenticator for my weblogic application. We have one managed srever under admin server . I have configured a Active Directory Authenticator named "ADAuthenticator" and made following changes as per the below values:
    I set the control flag to "OPTIONAL" .
    Security Realms-->myrealm-->Providers-->ADAuthenticator-->Provider Specific
    UserName Attribute : ServiceBEA
    Principal : ServiceBEA
    Host : xxxxxx
    User Search Scope : subtree
    Group From Name Filter : (&(ServiceBEA=%g)(objectclass=group))
    Credential : xxxxxx
    Confirm Credential : xxxxxx
    User From Name Filter : (&(ServiceBEA=%u)(objectclass=user))
    Static Group Name Attribute : ServiceBEA
    User Base DN : values provided as per requirement
    Port : 389
    User Object Class : user
    Use Retrieved User Name as Principal : checked
    Group Base DN : same values as per User Base DN
    Static Group Object Class : group
    Group Membership Searching : unlimited
    Max Group Membership Search Level : 0
    These are my AD settings. After doing this i click on save and then activate changes and then restarted the admin server.
    But the problem is when i login to weblogic console to check the user list under "User and Group" i am unble to find any Active Directory users.
    I don't know where i made the mistake. Can some make me out of this trouble.
    Any help is highly appreciated.
    Thanks in advance !

    Hi Sean,
    Actually we have already a Active Directory with username "ServiceBEA" in our windows server. So i used this "ServiceBEA" as UserName Attribute in weblogic console while creating a Active Directory Authenticator.
    You mean to say that we should go for "sAMAccountName" or what? If that is the case then i have also tested with following values, but still no luck.
    UserName Attribute : sAMAccountName
    Principal : ServiceBEA
    Host : xxxxxx
    User Search Scope : subtree
    Group From Name Filter : (&(sAMAccountName=%g)(objectclass=group))
    Credential : xxxxxx
    Confirm Credential : xxxxxx
    User From Name Filter : (&(sAMAccountName=%u)(objectclass=user))
    Static Group Name Attribute : sAMAccountName
    User Base DN : values provided as per requirement
    Port : 389
    User Object Class : user
    Use Retrieved User Name as Principal : checked
    Group Base DN : same values as per User Base DN
    Static Group Object Class : group
    Group Membership Searching : unlimited
    Max Group Membership Search Level : 0
    Please advise what to be place in case of User Name Attribute.
    Any help is highly appreciated.
    Thanks in advance !

  • Reporting Agent filename convention and result directory

    Hi Experts,
    We are using BW 3.1 so the questions below are refering to this version of BW.
    I have to run a query on a monthly basis which has many results depending on a cost center input.
    The problem is that I need to make a standard filename convention for the query results such as xxxxxx_yyyymm.html where xxxxxx is the actual cost center value, yyyy is the actual year and mm is the actual month.
    Is it possible to set this kind of naming convention in the Reporting Agent?
    Furthermore, I have to move the results into a standard directory of the Business Explorer Analyzer, namely EAIFILES/.....
    Can I redirect the results into the specified folder?
    Thanks and Regards,
    Dezso

    Dear Dezso,
    unfortunately this is not possible in Standard,
    you can download the data per download scheduler and send it to you needed location.
    In Transaction RSRAPS you can see the created files, it is not possible to change the file name.
    We have a solution to read the index file and rename the files to customized file names like yours, its possible but its alot of work.
    Regards Marcus

  • What is the maximum number of files that Finder can display in a directory?

    When displaying systems in an Active Directory domain, Finder only displays some of the systems.
    I presume that Finder is treating the list of SMB/CIFS systems as if they were entries in a file directory. The number of systems that should appear in the list is around 10,000 but only about half of these are displayed in Finder.
    Is there a way to increase the number of systems displayed in Finder?

    Yes, I am working with a Windows Active Directory domain.
    When using Finder>Network> to display systems in an Active Directory domain, it fails to display all of the systems. Is there a Finder limitation that causes this?
    When the system was originally brought online, only the local systems that were members of the Active Directory domain were displayed. Over time, the number of systems that have been "discovered" has increased. The entries are maintained in ascending alphabetical order. Currently, only systems with names beginnig with A through M are listed.
    This creates a bit of a problem for our Technical Publications group as all of the systems in our facility start with the letter T.
    Does Finder have a limit on how many entries that it can display for a given directory?
    Is the list of Active Directory systems being maintained in memory and, hence, limited by memory resources?
    Is there a way to filter the list?

  • Where to find the olb and pll directory

    hello, im trying to implement something i need to past two files in olb directory and pll directory, im using oracle10g
    where can i find those directories.. where are those folders?
    please reply asap

    Hello,
    There is no PLL directories or OLB directories. Just copy these files in one of the folder defined in the FORMS_PATH variable.
    Francois

  • Mac OS X disallow same folder name and filename under the same directory

    I noticed Mac doesn't allow me to create the same filename and folder name under the same directory.
    Seems like this constraint is unique only to Mac since I can do it in Unix and Windows.
    Why is this so?
      Mac OS X (10.4.9)  

    In Windows, there's probably a normally hidden extension being added to the file and/or the folder.
    In Unix, I'm NOT able to create both file "foo" and folder "foo". What version of Unix are you using that allows this? (Mac OS X is built on top of Unix.)
    One workaround would be to give the file a reasonable extension; foo.txt or foo.doc or foo.jpeg or whatever.
    Doug

Maybe you are looking for

  • Legacy asset data upload for multiple line items

    Hello Legacy asset data upload for multiple line items- for example Building is an asset which is having different line items for purchasing of land,constructaion or renovation etc.........now to upload the legacy data what should be consider...only

  • Applet in ie 5.0: class can not be Instantiated

    Hi! My problem is an Applet, which works fine with the appletviewer and with my iExplorer 5.0. But when I tried to install my Application (the Applet is part of a J2EE-WebApp) on the tomcat of an other computer, I get the "class can not be instantiat

  • IPad 3 as recording device - How to Connect Firewire 400 from a PreSonus device

    Have: iPad 3 (Apple 30-pin connector) PreSonus Firestudio (firewire 400 output) How to connect them? PreSonus had MIDI as well

  • I recently updated to 4.0 and my playlists disappeared

    I had 4 playlists 80's music, 90's, new rock etc and after installing the updated they are now gone. How do I create a new playlist now? I have spent hours on iTunes trying to figure it out, even drop and dragging music on already listed playlist and

  • Workflow- cost center supervisor

    Hi All, I have implemented Z-workflow for FI invoice with approvals at different levels. Cost center manager will approve at first level, if the invoice amount is greater than his limit, then the invoice will go to supervisor for further approval. Fo