How to retreive contents of a directory

I'm writing a java web application.
In one of my classes (standard class) I want to see what files are located in a specific directory. I just want to retreive all the filenames that are in that specific directory.
Could anyone give me some advice.
Thanks in advance
Jeroen

This should help:
import java.io.File;
String directoty =  "c:\\temp";
File f = new File( directoty );
if( ! f.isDirectory() )
  throw new IllegalArgumentException( "Path '" + directoty + "' is not a Directory" );
File[] dirContents =  f.listFiles();
System.out.println( "Files in Directory '" + directoty + "':\n" );
for( int i = 0; i < dirContents.length; i++ )
  System.out.println( "\t" + dirContents.getName() );
Good Luck!

Similar Messages

  • How to retreive contents ?

    We have used with most of the services available in the workbench but we are still not able to implement the following use case.
    1- Store a document into the Content management system, along with custom attributes (example: attach the "myAttribute"--->"toto" metatag to somedoc.pdf). We are only able to add pre-defined attributes from the accepted list.
    2- And, then how to retrieve this content using that metatag. We are able to retrieve the document using the name of the doc, but not a metatag.
    Can you confirm that this is indeed a feature of LC Content Management ? And that you can achieve that just by using the services already pre-defined in the workbench??

    > In your orchestration, create a new variable of type map
    > Introduce a set value operation which assigns map[@id=myAttribute] = toto
    > In your store Content operation property editor, in attributes map argument, select Variable or XPath instead of Literal and pass this map variable.
    > NOTE : You can also call a separate set Content Attributes operation in case you want to make use of pre-defined attributes also
    > NOTE : Dont worry about passing a single attribute in attributes map it doesnt flush out other existing attributes, only over-writes what we pass in the map.
    > Future releases will have searchRepository operation in which you can specify queries to find a document (i.e. it returns a node ID) you can search on basis of attribute values (exact or range or other conditions)

  • How to iterate contents of a directory?

    How do I iterate all the files and subdirectories of a directory, whose depth I don't know?

    A rough idea, you could do it recursively, but this is easier:
    import java.util.Stack;
    import java.util.Arrays;
    public
    class Pops
      public
      static
      void main(String[] args)
        File file = new File(args[0]);
        Stack stack = new Stack();
        Stack files = new Stack();
        stack.add(file);
        stack.addAll(Arrays.asList(file.listFiles()));
        while (!stack.empty())
          file = (File)stack.pop();
          if (file.isDirectory()) { stack.addAll(Arrays.asList(file.listFiles())); }      files.push(file);
        while (!files.empty())
          System.out.println(files.pop());

  • How to retreive contents of package spec and body over jdbc

    is there a query i can issue that would return the contents (both spec and body) of a database package? similar to "desc schema.pkg" ?
    i want to issue this query via jdbc and get back the contents of the package spec/body.

    solved:
    select * from user_source where name='my_pkg'
    Message was edited by:
    user612126

  • How to see the contents of a directory?

    ok, here is my problem. I need to see the contents of a directory (ie. like doing a dir in DOS or ls in Linux) and then process each of the files in the directory.
    Is there a way in java to see the contents of a directory? Please help...

    hi,
    well you can see the contents of a directory, a directory in turn could have files and subdirectories, so you could use the following snippet of code.
    import java.io.File;
    import java.io.IOException;
    public class FileBrowser
         private File mFile;
         public void listDirectory(String fileName)
              mFile = new File(fileName);
              if (mFile.exists()) //check if File or Directory with given name exists
                   if (mFile.isDirectory())
                        File mTempFile[] = mFile.listFiles();
                        if (mTempFile.length > 0)
                             for (int i=0; i < mTempFile.length; i++)
                                  listDirectory(mTempFile.getAbsolutePath()); //recursive call
                   else if (mFile.isFile())
                        printFilePath(mFile);
              else
                   throw new IllegalArgumentException("File or Directory does not exist");
         public void printFilePath(File file)
              System.out.println("File path :" + file.getAbsolutePath());
         public static void main(String args[])
              try
                   FileBrowser fb = new FileBrowser();
                   fb.listDirectory("c://temp//");
              catch(IllegalArgumentException ex)
    the above code snippet first figures out if a File object is representing a File or a Directory, if it represents a File it just call a method which prints out the Absolute path of the file which contains the file name also, else if it is a directory it just recursively scans through all sub-directories and files within the directory, also if the String arguement passed to listDirectory is incorrect, it throws a IllegalArguementException, hope this was useful.
    Cheerz

  • Read content of a directory

    Hi all,
    I'm searching for a way on how to read the content of a directory on a local machine..
    This has to be done in background.
    Does someone has an idea ?
    tia,
    Björn

    Hi Bjorn,
    try to search on and use the open dataset - read dataset - close dataset.
    Hope this helps.
    Regards,
    Vitz

  • Finder (Snow Leopard 10.6.8) taking long time to load contents of any directory. Please help?

    In my macbook pro 5,2 snow leopard (10.6.8), Finder taking long time to load contents of any directory. Please help?
    I have already tried to spotlight re-indexing but it did not help. I am hardly able to work on it, almost for each directory I browse its keeps on spinning for 1min.

    Download iTunes from Apple's web site and install it.  Don't use Software Update.

  • How to retreive and display output list from BAPI

    Hello
    I am making an applcation using SUP 2.0, and this application make an user to get leave history using a Mobile System from SUP.
    I've created the MBO as Attributes using the BAPI: BAPI_LEAVE_HISTORY.
    This BAPI has some parameters IN and OUT.
    Input parameters are Employee Id and date.
    The parameter OUT is a List that retreives the employee leave history.
    Anyone has an Idea or example how to retreive the output from BAPI and displaying the output on a screen.
    Any tips or blogs that can help me?
    Thanks all!
    Satish

    Hi David Brandow,
    I have tried your solution where I just created a MBO for my 'operation' and I'm using sync parameters to execute the RFC.
    The problem I'm facing is, for example, if I create a record it gets saved in the MBO table and the record successfully gets created in SAP as well after a sync. But when I create another record and sync, the previously saved record in MBO table also gets executed so I'm getting duplicate entries in SAP.
    Have you or anyone faced this problem?
    Any response is appreciated. Please let me know if I'm not clear, I realized its a complicated scenario.
    Thanks,
    Sandeep

  • How can I convert the volume directory into a single file installer?

    How can I convert the volume directory into a single file installer? I would like to hide all the miscillaneous files that I don't care for and be able to have the installer double click a single file and have it automatically install.

    On the second prompt screen when prompted 'What kind of self-extracting Zip file file do you want to make?'
    Are you choosing the second option (self-extracting Zip file for software installation)?
    I have a word file that I created to help me remember - is there anyway to email it to you?

  • I've had a hard drive crash and put in a new one.  However iTunes has or list all of them from my old drive.  How do we re-set the directory

    I've had a hard drive crash and put in a new one.  However iTunes has or list all of them from my old drive.  How do we re-set the directory?

    You can re-download the software from Download CS5.5 products
    Install and enter your serial number when prompted.
    Find your serial number quickly

  • How to find content of a constraint etc.

    Hi,
    select constraint_name
    from user_constraints
    where table_name = 'EMP';
    shows to two constraints for the given table of EMP. Now, how to find CONTENT of each of these two constraints?
    Secondly, how to find if a particular column is nullable (programmatically, not from DBA tool set)? e.g. EMP.deptno
    Thirdly, why did I get the err msg of "inserted value too large for column"
    when executing the following command for data insertion to EMP as user, scott
    create SEQUENCE emp_sequence
    start with 8000 increment by 10;
    insert into EMP values (emp_sequence.NEXTVAL,'JOE','Researcher',null,null,null,null,null);
    Thanks a bunch.

    Thirdly, why did I get the err msg of "inserted value too large for column"Er, do the math...
    SQL> conn scott/tiger
    Connected.
    SQL> desc emp
    Name                                      Null?    Type
    EMPNO                                     NOT NULL NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    SQL> select length('researcher') from dual
      2  /
    LENGTH('RESEARCHER')
                      10
    SQL>
    Secondly, how to find if a particular column is nullable (programmatically, not from DBA tool set)Don't like the sound of this, smells of dynamic coding. Anybody who can't figure out why they can't create an EMP record for a researcher probably ought not to be tangling with dynamic SQL just yet.
    Now, how to find CONTENT of each of these two constraints?The CONSTRAINT_TYPE tells you the sort of constraint: P=PRIMARY KEY, U=UNIQUE, R=FOREIGN KEY and C=CHECK. Only Check constraints have any content as such and you'll find that in the SEARCH_CONDITION. Note that this is a LONG column, so you may need need to SET LONG 5000 to see it in SQL*Plus.
    Cheers, APC
    P.S. In future please refrain from bundling unrelated questions into a single post. There is no charge for posting and it avoids the threads getting long and hard to follow.

  • How to install content server

    Hi all,
    I am new to DMS.How to install content server? and What is the difference between Content server and Kpro server?
    Thanks and Regards,
    Vairavan

    Hi Vairavan
    try SAP Service Marketplace at service.sap.com/contentserver and
    try the Installation Guides at service.sap.com/instguides -> SAP NetWeaver -> SAP NetWeaver 7.0 (2004s) -> Installation -> Installation u2013 Standaline Engines.
    regards, Andreas R

  • How to import your MS Active Directory users in an Oracle table

    Hello,
    I first tried to get a Heterogenous Connection to my MS Active Directory to get information on my Active Directory users.
    This doesn't work so I used an alternative solution:
    How to import your MS Active Directory users in an Oracle table
    - a Visual Basic script for export from Active Directory
    - a table in my database
    - a SQL*Loader Control-file
    - a command-file to start the SQL*Loader
    Now I can schedule the vsb-script and the command-file to get my information in an Oracle table. This works fine for me.
    Just to share my scripts:
    I made a Visual Basic script to make an export from my Active Directory to a CSV-file.
    'Export_ActiveDir_users.vbs                              26-10-2006
    'Script to export info from MS Active Directory to a CSV-file
    '     Accountname, employeeid, Name, Function, Department etc.
    '       Richard de Boer - Wetterskip Fryslan, the Nethterlands
    '     samaccountname          Logon Name / Account     
    '     employeeid          Employee ID
    '     name               name     
    '     displayname          Display Name / Full Name     
    '     sn               Last Name     
    '     description          Description / Function
    '     department          Department / Organisation     
    '     physicaldeliveryofficename Office Location     Wetterskip Fryslan
    '     streetaddress          Street Address          Harlingerstraatweg 113
    '     l               City / Location          Leeuwarden
    '     mail               E-mail adress     
    '     wwwhomepage          Web Page Address
    '     distinguishedName     Full unique name with cn, ou's, dc's
    'Global variables
        Dim oContainer
        Dim OutPutFile
        Dim FileSystem
    'Initialize global variables
        Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
        Set OutPutFile = FileSystem.CreateTextFile("ActiveDir_users.csv", True)
        Set oContainer=GetObject("LDAP://OU=WFgebruikers,DC=Wetterskip,DC=Fryslan,DC=Local")
    'Enumerate Container
        EnumerateUsers oContainer
    'Clean up
        OutPutFile.Close
        Set FileSystem = Nothing
        Set oContainer = Nothing
        WScript.Echo "Finished"
        WScript.Quit(0)
    Sub EnumerateUsers(oCont)
        Dim oUser
        For Each oUser In oCont
            Select Case LCase(oUser.Class)
                   Case "user"
                        If Not IsEmpty(oUser.distinguishedName) Then
                            OutPutFile.WriteLine _
                   oUser.samaccountname      & ";" & _
                   oUser.employeeid     & ";" & _
                   oUser.Get ("name")      & ";" & _
                   oUser.displayname      & ";" & _
                   oUser.sn           & ";" & _
                   oUser.description      & ";" & _
                   oUser.department      & ";" & _
                   oUser.physicaldeliveryofficename & ";" & _
                   oUser.streetaddress      & ";" & _
                   oUser.l           & ";" & _
                   oUser.mail           & ";" & _
                   oUser.wwwhomepage      & ";" & _
                   oUser.distinguishedName     & ";"
                        End If
                   Case "organizationalunit", "container"
                        EnumerateUsers oUser
            End Select
        Next
    End SubThis give's output like this:
    rdeboer;2988;Richard de Boer;Richard de Boer;de Boer;Database Administrator;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Richard de Boer,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;
    tbronkhorst;201;Tjitske Bronkhorst;Tjitske Bronkhorst;Bronkhorst;Configuratiebeheerder;Informatie- en Communicatie Technologie;;Harlingerstraatweg 113;Leeuwarden;[email protected];;CN=Tjitske Bronkhorst,OU=Informatie- en Communicatie Technologie,OU=Afdelingen,OU=WFGebruikers,DC=wetterskip,DC=fryslan,DC=local;I made a table in my Oracle database:
    CREATE TABLE     PG4WF.ACTD_USERS     
         samaccountname          VARCHAR2(64)
    ,     employeeid          VARCHAR2(16)
    ,     name               VARCHAR2(64)
    ,     displayname          VARCHAR2(64)
    ,     sn               VARCHAR2(64)
    ,     description          VARCHAR2(100)
    ,     department          VARCHAR2(64)
    ,     physicaldeliveryofficename     VARCHAR2(64)
    ,     streetaddress          VARCHAR2(128)
    ,     l               VARCHAR2(64)
    ,     mail               VARCHAR2(100)
    ,     wwwhomepage          VARCHAR2(128)
    ,     distinguishedName     VARCHAR2(256)
    )I made SQL*Loader Control-file:
    LOAD DATA
    INFILE           'ActiveDir_users.csv'
    BADFILE      'ActiveDir_users.bad'
    DISCARDFILE      'ActiveDir_users.dsc'
    TRUNCATE
    INTO TABLE PG4WF.ACTD_USERS
    FIELDS TERMINATED BY ';'
    (     samaccountname
    ,     employeeid
    ,     name
    ,     displayname
    ,     sn
    ,     description
    ,     department
    ,     physicaldeliveryofficename
    ,     streetaddress
    ,     l
    ,     mail
    ,     wwwhomepage
    ,     distinguishedName
    )I made a cmd-file to start SQL*Loader
    : Import the Active Directory users in Oracle by SQL*Loader
    D:\Oracle\ora92\bin\sqlldr userid=pg4wf/<password>@<database> control=sqlldr_ActiveDir_users.ctl log=sqlldr_ActiveDir_users.logI used this for a good list of active directory fields:
    http://www.kouti.com/tables/userattributes.htm
    Greetings,
    Richard de Boer

    I have a table with about 50,000 records in my Oracle database and there is a date column which shows the date that each record get inserted to the table, for example 04-Aug-13.
    Is there any way that I can find out what time each record has been inserted?
    For example: 04-Aug-13 4:20:00 PM. (For my existing records not future ones)
    First you need to clarify what you mean by 'the date that each record get inserted'.  A row is not permanent and visible to other sessions until it has been COMMITTED and that commit may happen seconds, minutes, hours or even days AFTER a user actually creates the row and puts a date in your 'date column'.
    Second - your date column, and ALL date columns, includes a time component. So just query your date column for the time.
    The only way that time value will be incorrect is if you did something silly like TRUNC(myDate) when you inserted the value. That would use a time component of 00:00:00 and destroy the actual time.

  • I have my personal music (not purchased from Itunes) stored in two locations, on my PC and on an external HD. How can I find out which directory itunes uses to access this music? I am using Itunes version 11.4.0.18. Thanks

    I have my personal music (not purchased from Itunes) stored in two locations, on my PC and on an external HD. How can I find out which directory itunes uses to access this music? I am using Itunes version 11.4.0.18. Thanks

    Many thanks JEM24 for your help.  Ive just spent the best part of six hundred pounds on a new Sony Rx100m2 compact camera, so I have no interest in the Ipods camera at all really. I doubt Ill be watching many videos on it as Im very lucky in that I have a good Android tablet. Its more as a stock music player that Ill be buying the Ipod for, if indeed I do end up buying one. I dont like the idea of paying the exorbitant amount added for more memory space that Apple along with most other companies charge. In fact I read an article on this very subject just yesterday in the tech section of Flipboard. It stated in the article that in the case of the Iphone  the actual cost of each additional  gigabyte of storage  to Apple et al is something in the order of 60p.. This is certainly not reflected in the price us the customer has to pay at the till.. Its for this reason primarily that Apple in particular, because their products do not allow adding expandable memory of your own in the form of cheap to buy cards, that nobody in their right mind buys the 64gig etc Iphones..I am aware that we are discussing my potential purchase of an Ipod Touch here but you see my point. Many thanks again though for helping me.

  • How do I change the "Default Directory" associated with my subscription?

    I was recently added as an administrator for a client's Azure subscription.  This has caused his account AD to be the default directory I see when I log in.  So every time I log in I have to open the Subscriptions menu and change the FILTER BY
    DIRECTORY option.  How can I make my own directory the default directory when I log in?
    Note: there was an almost identical question back in Dec 2013 and the solution was to have the other user remove you as an administrator.  The marked answer suggested the questioner read some arcane description of Azure subscriptions and Active Directory.
      I need to remain an admin for the other account and the referenced document had nothing useful to say about my problem.
    Anyway, thanks in advance for your help.

    Hi,
     Thank you for posting.
     I hope you find the following link helpful.
     http://itproguru.com/expert/2014/07/change-azure-subscriptionsgo-directly-to-a-specific-subscription-in-windows-azurestep-by-step/
    Regards,
    Nithin Rathnakar.

Maybe you are looking for

  • Using FMS v4.5.5 with a browser-based audio player running on iPad/iPhone

    Hello, I’m seeking some clarity/guidance on using FMS v4.5.5 (Streaming Edition) with a browser-based audio player running on iPad/iPhone (i.e. under iOS). Background I have a Microsoft Windows 2008 R2 Web Server running IIS v7.5 and supporting a web

  • HT201335 how to use it in macbook pro please?

    I want to connect the airplay mirroring in my macbook pro but its not working i chicked the wifi and everythig but i cant find the airplay mirroring option in the display setting what to do please???

  • Pricing in crm standalone server

    Hi All, Can anybody tell me how to configure pricing in standalone server. If it is possible can anybody send me the document for configuration? Thanx Saravana

  • Trying to create PDFs with MS Office v. 10...HELP!!

    Hello all, I've got MS OFFICE v. 10. I've got some Excel files that I'm trying to save as a PDF. When I do command P and save as PDF, the PDF file shows up for a split second then disappears. What's the problem? Thanks Message was edited by: byrdbrai

  • Need to Create a Report on 0TCT_C01 as No of  Navigations for Queries.

    Hi, I have  a report Requirement on 0TCT_C01 as Number of Navigations for Queries. already we are activated the Info Cube and loaded the data, now the data is avalible in the Cube. Report like  In Column Fields: Validity Period :Query:No of Navigatio