How to read the filename

I have a bunch of files in a directory. How to read just the filename from the directory.

Following code will read the contents in a directory into a temporary table. The code comes from "expert one-on-one" from thomas kyte.
Remember to set the java privileges correctly for the directorys you want to create the list from.
greetings
Freek D
CREATE GLOBAL TEMPORARY TABLE DIR_LIST
( FILENAME VARCHAR2(255) )
ON COMMIT DELETE ROWS
CREATE OR REPLACE
AND COMPILE java source named "DirList"
AS
import java.io.*;
import java.sql.*;
public class DirList{
public static void getList(String directory) throws SQLException{
File path = new File( directory );
String[] list = path.list();
String element;
for(int i = 0; i < list.length; i++){
element = list;
#sql {
INSERT INTO DIR_LIST (FILENAME)
VALUES (:element) };
CREATE OR REPLACE PROCEDURE GET_DIR_LIST (
P_DIRECTORY IN VARCHAR2)
AS
LANGUAGE JAVA
NAME 'DirList.getList( java.lang.String )';
BEGIN
DBMS_JAVA.GRANT_PERMISSION (
USER,
'java.io.FilePermission',
'c:\temp',
'read');
END;
EXEC get_dir_list( 'c:\temp' );
SELECT *
FROM DIR_LIST
WHERE ROWNUM < 5;

Similar Messages

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • Help on how to read the content of an XML file from the payload

    I have a receiver channel / mail adapter, that sends e-mails with a XML attachment.
    I’m trying to write a Bean, that should make it possible to rename the attached XML file dynamically.
    In the Bean I want to read the content of the attached XML file, it could be the “order number”.
    The filename should then be “Order number”.XML.
    <u><i>Can anyone help me with how to read the content of the XML file from the payload.</i></u>
    <i><b>Frank</b></i>

    hi,
    check this: http://jakarta.apache.org/poi/

  • During checkin read the filename in oracle ucm

    During Checkin content from Profile I want to read the filename. Can we do this using Java filter?How?

    Hi Srinath,
    1) Whatever given code I placed in rule side effect and checkin content to content server and verified in the console output, could not find the trace log.
    2) I placed code in custom placed checkin  content and got below error
    Caused by: java.lang.IllegalArgumentException: !csDynHTMLArgumentMessage2,3,<$if &lt;$trace("content id side effect"\, "#0023console")$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 [[% start with original filename\, which may include path and/or extension %]]
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$filename=#0023local.primaryFile$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 [[% replace any backslashes with normal slashes %]]
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$filename=strReplace(filename\,"\\\\"\,"/")$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 [[% remove any leading text up to last slash %]]
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$filename=regexReplaceFirst(filename\,"^.*/"\,"")$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 [[% remove any trailing text starting with a dot and followed by anything other than a dot %]]
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$filename=regexReplaceFirst(filename\,"\\.[^.]+$"\,"")$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$trace(filename\, "#0023console")$&gt;
    services/3 04.21 00:06:43.026 IdcServer-427 &lt;$dpPromote("dDocName"\, AutoNumberPrefix & "_" & filename)$&gt;$> <$isActive=1$> <$endif$>!csParserUnableToFindClosingElement,\s
    services/3 04.21 00:06:43.026 IdcServer-427        at intradoc.common.DynamicHtmlMerger.createArgumentException(DynamicHtmlMerger.java:2118)
    services/3 04.21 00:06:43.026 IdcServer-427        at intradoc.common.DynamicHtmlMerger.evaluateScriptToWriter(DynamicHtmlMerger.java:1907)
    services/3 04.21 00:06:43.026 IdcServer-427        at intradoc.common.DynamicHtmlMerger.evaluateScriptNoErrorHandling(DynamicHtmlMerger.java:1866)
    services/3 04.21 00:06:43.026 IdcServer-427        at intradoc.common.DynamicHtmlMerger.evaluateScriptReportError(DynamicHtmlMerger.java:1841)
    services/3 04.21 00:06:43.026 IdcServer-427        at intradoc.server.DocProfileStates.computeIsRuleActivated(DocProfileStates.java:642)

  • How to read the content in one node of XML in Java? Pls help

    My dear brothers,
    I am a newbie of XML, I have a exercise which is creating a Tree View from XML file. But the trouble is I do not know how to read the content in one node of XML file. I decide to use the algorithm as following:
    1. Create a GUI form which gives the ability for user to choose a XML file (ok)
    2. Load XML and return the file (ok)
    3. Read the file from node to node to create the node in Tree View (?!)
    Please help me, and if you are enough kind, please give me an small example to easy understand. Thanks in advance.
    Hoang Yen Binh

    I hope this one helps you.
         <ABC Type="ProductBased" ProdName="One" Location="India">
              <CEO>Raj</CEO>
              <Finance>Vikram</Finance>
              <HR>Karthik</HR>
              <Technical>Satish</Technical>
         </ABC>
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.NamedNodeMap;
    import org.w3c.dom.Attr;
    import org.w3c.dom.NodeList;
    import org.w3c.dom.Node;
    import org.w3c.dom.DOMException;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import java.io.File;
    import java.io.IOException;
    public class XmlReading {
         Document doc;
         Element element;
         public static void main(String[] args) throws Exception{
              XmlReading xr = new XmlReading();
              xr.getXmlParser(args);
         public void getXmlParser(String[] args) {
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                   if(args.length != 1) {
                        System.err.println("Argument Required");
              try {
                   DocumentBuilder builder = factory.newDocumentBuilder();
                   doc = builder.parse(new File(args[0]));
              }catch(ParserConfigurationException e1) {
              }catch(SAXException e2) {
              }catch(IOException e3) {
              getAttributes();
         public void getAttributes() {
              // Retrive the entire Document from the Dom Tree
              element = doc.getDocumentElement();
    //          System.out.println(element);
              NamedNodeMap attrs = element.getAttributes();
              // Get number of attributes in the element
         int numAttrs = attrs.getLength();
         // Process each attribute
              for (int i=0; i<numAttrs; i++) {
                   Node node = attrs.item(i);
                   // Get attribute name and value
                   String attrName = node.getNodeName();
                   String attrValue = node.getNodeValue();
                   System.out.println(attrName + ": " + attrValue);
              String s1 = element.getTagName();
              System.out.println(s1);
              // To get all the elements in a DOM Tree
              NodeList nl1 = element.getElementsByTagName("*");
              int i2 = nl1.getLength();
              System.out.println(i2);
              for(int i=0; i<i2; i++) {
                   System.out.println(nl1.item(i) + "\n");
    }

  • How to read the data in excel sheet

    Dear sir,
    How to read the data in excel sheet when i recieve a data serial communication... ie i have store a data in excel such that
    Cell A       Cell B
       A           Apple 
       B           Ball
       C           Cat
       D           Doll
    when i recieve A from serial communication i have to display Apple, and when i recieve B i have to display Ball and so on.. 

    Hi, 
    I would recommend you to have a look at the VI attached. It makes use of a VI named 'Read from Spreadsheet' to read the row and column data from the tab delimited excel file. The read data is then searched for the Alphabet specified and finally returns you the corresponding string. The test file used to validate the operation of the VI is also attached. 
    Trust this would help you solve the issue. 
    Regards, 
    Sagar G Yadav | Application Engineer | National Instruments
    Attachments:
    read_from_excel.vi ‏10 KB
    Book1.txt ‏1 KB

  • How to read the check box value in alv report

    hi experts,
    i m working on one alv report where i m using the check box for field selection in alv display.
    but i don't know how to read the only selected fields.
    wa_fieldcat-fieldname = 'BOX'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Box'.
      wa_fieldcat-checkbox = 'X'.
      wa_fieldcat-input = 'X'.
      wa_fieldcat-edit = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'AUFNR'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Sales Doc'.
      wa_fieldcat-hotspot = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = v_repid
         I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         it_fieldcat                       = i_fieldcat[]
         i_save                            = 'A'
         it_events                         = v_events
        TABLES
          t_outtab                          = it_header
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
    when '&RELEAS'.
    endcase
    endform.
    i gone through some already posted que for same problem i tried options like
    loop at it_header.
    endloop.
    but i m getting box field empty.
    is there i missed something? plz sugeest.. if u have any other solution plz post...

    Have this code in your user command fm:
    * For capturing changed data
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = w_grid.
      CALL METHOD w_grid->check_changed_data
        IMPORTING
          e_valid = w_valid.
      IF w_valid = 'X'.
    loop at itab where mark = 'X'.
    endloop.
    ENDIF.
    Regards,
    Ravi

  • How to read the Variance Analysis report S_ALR_87013139,  Pdt cost by Order

    Hi,
    Could someone tell me how to read the variance analysis report, S_ALR_87013139 - Cumulative for product cost by order. The report has the following fields, Target (Debits),     Actual (Debits),     Scrap,     Var. Without Scrap,     Work in Process(WIP),     Control Costs.
    I am looking to find how the numbers add up.
    Thanks for your help.
    Ram
    Message was edited by:
            Ram R

    Thanks Sridhar,
    When I analyse the report S_ALR_87013139 - Cumulative , for a product for a period (with no scrap), I get the following
    Target (Deb) -   46,855.55
    Act (Deb) - 58,315.87
    Scrap - 0.00
    Var W/O- Scrap -  11,269
    WIP- 0
    Control Cost - 0
    Here Actual - Target is not equal to Variance. What could be the issue?
    Could you please tell me how SAP would update this report  with target & actual costs with respect to open production orders, carried over from previous periods.
    Thanks,
    Ram

  • How to read the contents of attached files

    Hi,
    I am designing a Form using LiveCycle Designer 8.0
    Scenario:
    User can attach the file through "Attachments" facility provided on Adobe  Reader.
    The requirement is to attach 3 documents and post it to SAP system using Web services.
    I am using the following code(which i got from this forum only) to find the number of files user has attached.
    d = event.target.dataObjects;
    n =  d.length;
    xfa.host.messageBox("Number  of Attachments: "+n);
    //Displaying  the names of the Attached files
    for( i =  0; i < n; i++ )
    xfa.host.messageBox("Name  of the file: "+d[i].name);
    My problem: is how to read the contents of the attached files so that I post it to SAP using Web services
    Thanks in advance!!
    Taha Ahmed

    In order to read the content of the Redo Log files, you should use Logminer Utility
    Please refer to the documentation for more information:
    [Using LogMiner to Analyze Redo Log Files|http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/logminer.htm#SUTIL019]
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com
    [Step by Step install Oracle on Linux and Automate the installation using Shell Script |http://kamranagayev.wordpress.com/2009/05/01/step-by-step-installing-oracle-database-10g-release-2-on-linux-centos-and-automate-the-installation-using-linux-shell-script/]

  • How to read the and Write the PDF file give me the solution

    Hi all,
    How to read the and Write the PDF file give me the solution
    My coding is
    import java.io.File;
    import com.asprise.util.pdf.PDFImageWriter;
    import com.asprise.util.pdf.PDFReader;
    import java.io.*;
    import java.io.FileOutputStream;
    public class example {
    // public example() {
         public static void main(String a[])
              try
              PDFReader reader = new PDFReader(new File("C:\\AsprisePDF-DevGuide.pdf"));
                   reader.open(); // open the file.
                   int pages = reader.getNumberOfPages();
                   for(int i=0; i < pages; i++) {
                   String text = reader.extractTextFromPage(i);
                   System.out.println("Page " + i + ": " + text);
    // perform other operations on pages.
    PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("c:\\new11.pdf"));
                   writer.open();
                   writer.addImage("C:\\sam.doc");
                   writer.close();
                   System.out.println("DONE.");
    reader.close();
              catch(Exception e){System.out.println("error:"+e);
              e.printStackTrace();
    I get the pdf content then it returns the string value but ther is no option to write the string to PDF, and we only add a image file to PDF,but i want to know how to wrote the string value to PDF file,
    Please give response immtly
    i am waiting for your reply.
    thanks,
    Suresh.G

    I have some question flow
    How library to use this code.
    I try runing but have not libary.
    Please send me it'library
    Thank you very much!

  • How to read the data from Excel file and Store in XML file using java

    Hi All,
    I got a problem with Excel file.
    My problem is how to read the data from Excel file and Store in XML file using java excel api.
    For getting the data from Excel file what are all the steps i need to follow to get the correct result.
    Any body can send me the code (with java code ,Excel sheet) to this mail id : [email protected]
    Thanks & Regards,
    Sreenu,
    [email protected],
    india,

    If you want someone to do your work, please have the courtesy to provide payment.
    http://www.rentacoder.com

  • Help me...How to read the content if "Transfer-Encoding:chunked" is used?

    I am doing a project for internet control using Java,PHP and MySql.All sites should go through the proxy server only.If the HTTP header contains Content-Length,am getting the content length as below:
    public class HTTPResponseReader extends HTTPMessageReader
        String statusCode;
        public HTTPResponseReader(InputStream istream) throws IOException,                     NoSuchElementException
      BufferedInputStream distream = new BufferedInputStream(istream);
      retrieveHeader(distream);
      StringTokenizer st =  new StringTokenizer(new String(HTTPMessageReader.toArray(header)));
      versionProtocol = st.nextToken();
      statusCode = st.nextToken();
      String s;
      while (st.hasMoreTokens())
            s = st.nextToken();
            if (s.equals("Transfer-Encoding:"))
           transferEncoding = new String(st.nextToken());
         if (s.equals("Content-Length:"))
           contentLength = Integer.parseInt(st.nextToken());
         if (s.equals("Connection:"))
          connection = new String(st.nextToken());
          if (connection.equals("keep-alive")) mustCloseConnection = false;
       retrieveBody(distream);     
    }After getting the Content-Length,i used read method to read the content upto that content length.Then i concatenated the HTTP header and body and the requested site was opened.But some sites dont have Content-Length.Instead of that,Transfer-Encoding is used.I got the HTTP Response header as "Transfer-Encoding:chunked" for some sites.If this encoding is used how to get the length of the message body and how to read the content.
    Can anybody help me.
    Thanks in advance...
    Message was edited by:
    VeeraLakshmi

    Why don't you use HttpUrlConnection class to retrieve data from HTTP server? This class already supports chunked encoding...
    If you want to do anything by yourself then you need to read HTTP RFC and find all required information. Well in two words you may reject advanced encoding by specifying HTTP 1.0 in your request or download chunked answer manually. Read RFC anyway :)

  • How to read the content of a text file (by character)?

    Guys,
    Good day!
    I'm back just need again your help. Is there anyone knows how to read the content of a text file not by line but by character.
    Please help me. Thank you so much in advance.
    Jojo

    http://java.sun.com/javase/6/docs/api/index.html
    package java.io
    InputStream.read(): int
    Reads the next byte of data from the input stream.
    Implementation:
    InputStreamReader
    An InputStreamReader is a bridge from byte streams to character streams: It reads bytes and decodes them into characters using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.

  • While saving a pdf file opened by foxit reader, the filename will be some strings

    '''''i opened a pdf file in firefox with foxit reader, the filename was ,for
    example, ol20120327.pdf, and i click the save and i got i file , the filename just some strings , not the real name. It really bothers me for a long time. ps: while in ie, maxhon ,they got the right name.
    i don't want change my default browser; i love firefox. i hope the problem would be solved. Thanks a lot''.'''

    try adobe reader

  • How to read the whole name of a music title while scrolling down a list of titles? With the new iOs7 Music App there is no more black box showing the entire name!

    How to read the whole name of a music title while scrolling down a list of titles? The old software-app had the function to click for a longer time on a titles beginning letters until a black box revealed the entire name. I miss this function especially for my classical music, because lots of pieces start with similar words. E.g.:
    "Beethoven: Variations On "Ein Mädchen Oder Weibchen", Op. 66 - Var. 1"
    "Beethoven: Variations On "Ein Mädchen Oder Weibchen", Op. 66 - Var. 2"
    Scrolling in a list of title, I can't distinguish the titles, because just the first words are shown followed by: "...".
    That's horrible!

    Or you could include a width to your body style:
    body {
    background-image: url(Logo/sky1.jpg);
    background-position: center center;
    background-attachment: fixed;
    width: 75%;}
    It might work or not depending on your other color scheme.

Maybe you are looking for

  • How do I turn off home sharing on devices I can no longer access?

    I have an old iPhone and an old PC which I no longer have access to (the iPhone is broken beyond fixing and the pc I gave up on months ago) I would like to remove them from my home sharing list to open up room. With the two unused devices I have the

  • Image swaps with fade out and in

    I am new to Dreamweaver, in fact only got into it to do my own website. I want to create image swaps with a fade out and then fade in with the new image. Nowhere can I find out how to do this so far. Can anybody point me in the right direction. Many

  • ASR1002 - For DNS it seems that NAT doesn't work correctly

    Hi Folks, For DNS it seems that NAT doesn't work correctly The ASR 1002 works as a NAT-Router. But for DNS it seems that NAT doesn't work correctly. All DNS packets with a frame size greater than 512byte are not processed (they donїt arrive at the DN

  • Can you do 3D composition in Motion yet?

    Or are there any workarounds? I saw a tutorial on how to make a building in Motion and I wouldn't mind trying to place it somewhere in a video. Can I use a 4 point tracker to rotate and scale the bottom 4 corners, while tracking 4 dots in a video? It

  • Smart Connect bug

    Cheers, glad I could help.