Searching a string in a pdf blob

Hi,
My requirement is finding a string in a blob data. I am using
dbms_lob.INSTR(FILE_DATA, utl_raw.cast_to_raw('Tag Switch'),1,1) > 0 approach.
It is working properly for doc htm, text formats. But when we try to search in pdf blobs, it isn't working.
Can someone suggest a solution for this issue?

You can use Oracle Text to search your words in pdf files.
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE    10.2.0.3.0      Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> /* Creating my demo table */
SQL> CREATE TABLE pdm(id_pk INTEGER,fname VARCHAR2(30),pdf_file BLOB);
Table created.
SQL> /* Creating the directory object for latter use */
SQL> CREATE OR REPLACE DIRECTORY TEMP AS 'c:\';
Directory created.
SQL> /* Creating a procedure which will load the BLOBs (pdf files) into the table */
SQL> CREATE OR REPLACE PROCEDURE load_file(pi_id IN INTEGER, pfname IN VARCHAR2) IS
  2    src_file BFILE;
  3    dst_file BLOB;
  4    lgh_file BINARY_INTEGER;
  5  BEGIN
  6    src_file := bfilename('TEMP', pfname);
  7 
  8    INSERT INTO pdm
  9      (id_pk, fname, pdf_file)
10    VALUES
11      (pi_id, pfname, EMPTY_BLOB())
12    RETURNING pdf_file INTO dst_file;
13 
14    DBMS_LOB.OPEN(src_file, dbms_lob.file_readonly);
15    lgh_file := dbms_lob.getlength(src_file);
16    DBMS_LOB.LOADFROMFILE(dst_file, src_file, lgh_file);
17    dbms_lob.close(src_file);
18    COMMIT;
19  END load_file;
20  /
Procedure created.
SQL> EXECUTE load_file(1,'plsql_new_in_11gr1.pdf');
PL/SQL procedure successfully completed.
SQL> EXECUTE load_file(2,'Model clause.pdf');
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT id_pk,fname,DBMS_LOB.getlength(pdf_file)
  2  FROM pdm;
     ID_PK FNAME                          DBMS_LOB.GETLENGTH(PDF_FILE)
         1 plsql_new_in_11gr1.pdf                               170264
         2 Model clause.pdf                                    4288164
SQL> /* Creating the index */
SQL> CREATE INDEX pdm_pdf_idx ON pdm(pdf_file) INDEXTYPE IS CTXSYS.CONTEXT;
Index created.
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER, 'PDM', cascade=>TRUE);
PL/SQL procedure successfully completed.
SQL> SELECT id_pk,fname
  2  FROM pdm
  3  WHERE CONTAINS(pdf_file,'PL/SQL')>0;
     ID_PK FNAME
         1 plsql_new_in_11gr1.pdf
SQL> SELECT id_pk,fname
  2  FROM pdm
  3  WHERE CONTAINS(pdf_file,'Fine-grained access control')>0;
     ID_PK FNAME
         1 plsql_new_in_11gr1.pdf
SQL> SELECT id_pk,fname,DBMS_LOB.getlength(pdf_file)
  2  FROM pdm;
     ID_PK FNAME                          DBMS_LOB.GETLENGTH(PDF_FILE)
         1 plsql_new_in_11gr1.pdf                               170264
         2 Model clause.pdf                                    4288164
SQL> SELECT id_pk,fname
  2  FROM pdm
  3  WHERE CONTAINS(pdf_file,'Saubhik')>0;
no rows selected
SQL> EXECUTE load_file(3,'plsql_conditional_compilation.pdf');
BEGIN load_file(3,'plsql_conditional_compilation.pdf'); END;
ERROR at line 1:
ORA-12899: value too large for column "SCOTT"."PDM"."FNAME" (actual: 33,
maximum: 30)
ORA-06512: at "SCOTT.LOAD_FILE", line 8
ORA-06512: at line 1
SQL> EXECUTE load_file(3,'conditional_compilation.pdf');
PL/SQL procedure successfully completed.
SQL> SELECT id_pk,fname,DBMS_LOB.getlength(pdf_file)
  2  FROM pdm;
     ID_PK FNAME                          DBMS_LOB.GETLENGTH(PDF_FILE)
         1 plsql_new_in_11gr1.pdf                               170264
         2 Model clause.pdf                                    4288164
         3 conditional_compilation.pdf                          540594
SQL> EXEC DBMS_STATS.GATHER_TABLE_STATS(USER, 'PDM', cascade=>TRUE);
PL/SQL procedure successfully completed.
SQL> SELECT id_pk,fname
  2  FROM pdm
  3  WHERE CONTAINS(pdf_file,'conditional')>0;
     ID_PK FNAME
         1 plsql_new_in_11gr1.pdf
         3 conditional_compilation.pdf
SQL> SELECT id_pk,fname
  2  FROM pdm
  3  WHERE CONTAINS(pdf_file,'The Catch 22')>0;
     ID_PK FNAME
         3 conditional_compilation.pdf
SQL>

Similar Messages

  • Search does not find text string in a PDF file

    Some of the PDFs on my company's website have text that does not come up in a search of the PDF. You can see the text on the page, but it's ignored in a search. When I open the PDF and use the Select tool to copy the six-character string, then paste it into the Search field of the open PDF, the string pastes into the Search window as open boxes. While that might explain why the string is not found in the search, I'm confused about why the characters are correct on the PDF page, but not after they are copied and pasted.
    Here is an example: Search for this word in the attached PDF file:
    control
    The search will miss the first occurrence of Control in the first bullet on the page.

    Most of the fonts are embedded (except 1), but that does not mean you can search them as mentioned. The simplest way to avoid the problem is to go back to more standard fonts, like Arial, Courier, Times New Roman, and such. You may still have a problem with MAC users where they have Helvetical and Times Roman as standard. However, most of the common fonts have the same character associations and it is likely not a problem.

  • How to search a string in some folder.

    Hi ,
    In my application users will upload some pdf,xls files to server. files will be saved in server. From the front end can search on all files with some specific string. If that string is there in any of the file, user has to get link to download that file and the text just before and after that user string. Its like how we get in google. This type of search we need to implement, Could any one please let me know how to implement, any free API are there in java. Please its urgent, help on this.
    Thanks
    Mohan

    user594301 wrote:
    I have 2 columns in a table. entry_no and msg_txt. entry_no is number(12) and msg_txt is LONG. I want to search one string in msg_txt. How can I write a query for this ?You can't write a query for this. The only thinks you can do with a long in a query is put something in and take it out again - with diffiuclty, usually.
    You can write a PL/SQL function to do this for you if necessary. The function will have to perform the search directly if the long < 32760 bytes or use DBMS_SQL to break the LONG up into 32760 byte segments that can then be manually searched. If you are lucky someone has done this already and posted the code online. Either way the solution will be slow and probably painful to implement.
    If possible convert your data to a CLOB and use DBMS_CLOB to find the data you need.

  • Can Azure Search support indexing of documents (pdf, doc etc)

    Hi,
    I want to implement the azure search service indexing of documents (pdf, docs etc). is it possible ? if yes, then how ?
    Thanks

    Hi Shib,
    I wanted to respond with a few ideas based on your question.  As of today, we do not have a document cracker for Azure Search to allow you to index the content from files such as the ones you suggested.  This is a pretty highly requested feature
    (http://feedback.azure.com/forums/263029-azure-search/suggestions/6328662-blob-indexing-w-file-crackers), but we have not too date been able
    to prioritize this. 
    In the meantime, somethings you might consider looking at are iFilter or Apache Tika.  These are both great options that would allow you to programmatically extract the text from these files.  Based on the extracted text you could then post the
    content to Azure Search.  I personally think this example on CodeProject is a pretty good starting point if you were to consider using iFilter:
    http://www.codeproject.com/Articles/13391/Using-IFilter-in-C
    I hope that helps.
    Liam
    Sr. Program Manager, SQL Azure Strategy -
    Blog

  • How to load a PDF blob?

    Hi, could some one help me with the steps to loading a DPF file into a table. In this table I have a column which is a BLOB datatype where I would like to store these PDF's.
    Any help would be greatly appriciated!
    Thanks for your time.

    CREATE OR REPLACE PROCEDURE load_pdf_blob IS
    dest_loc BLOB;
    src_loc BFILE;
    Amount INTEGER;
    new_dir string(1000) := 'test_dir';
    new_file string(1000) := 'test_pdf.pdf';
    BEGIN
    src_loc := BFileName(new_dir,new_file);
    Amount := dbms_lob.getlength(src_loc);
    insert into test_pdf (sno,pdf_file)
    values (seq_val,empty_blob());
    DBMS_LOB.OPEN(src_loc, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.OPEN(dest_loc, DBMS_LOB.LOB_READWRITE);
    DBMS_LOB.LOADFROMFILE(dest_loc, src_loc, Amount);
    DBMS_LOB.CLOSE(dest_loc);
    DBMS_LOB.CLOSE(src_loc);
    COMMIT;
    END load_pdf_blob;
    /

  • How to show in a report a pdf blob from database

    Hi all
    We are working on report 6i and report 10. We have a report wich needs to show a blob field from database that storages a pdf (type application/pdf). OLE2 is deprecated. The pdf blob field must be displayed in a preview and must be printed. In local, it works. When it works on a browser, the pdf blob field is missing. If we load the field into a pdf file, the field is not visible in the browser.
    Do not get it to work. How I can implement? Could you give us any example for this?

    In local, it works. What do you mean by that exactly? You see the pdf in Reports Builder?
    If you just want to show the pdf in a browser (not embedded in a report) it is easy to use mod_plsql. You can have a simple db procedure like this to show any kind of blob:
    procedure show_webdoc(io_blob    in out nocopy blob
                         ,i_mimetype in varchar2
                         ,i_filename in varchar2)
    is
    begin
       if dbms_lob.getlength(io_blob) >0 then
          owa_util.mime_header(nvl(i_mimetype,'application/octet'),false);
          htp.p('Content-length: ' || dbms_lob.getlength(io_blob));
          htp.p('Content-Disposition:  inline; filename="'||i_filename|| '"');
          owa_util.http_header_close;
          wpg_docload.download_file(io_blob);
       end if;
    end show_webdoc;

  • How to replace string in existing pdf using pdfbox?

    My requirement:
    Your loan amount @loanamount is approved.
    I wanted to replace @loanamount to 5,00,000. If i try with pdfbox api,i am not able to replace. i am getting empty space in pdf.
    If i use same api and if try to replace @loanamount to abcd. now its replacing
    replaceFirst("@loanamount","5,00,00"); - not able to replace. getting empty content in pdf
    public void replaceString()
    PDDocument doc = null;
    try {     
    doc = PDDocument.load("D:/DOCS/Letter.pdf"); //Input PDF File Name
    List pages = doc.getDocumentCatalog().getAllPages();
    for (int i = 0; i < pages.size(); i++)
    PDPage page = (PDPage) pages.get(i);
    PDStream contents = page.getContents();
    PDFStreamParser parser = new PDFStreamParser(contents.getStream());
    parser.parse();
    List tokens = parser.getTokens();
    for (int j = 0; j < tokens.size(); j++)
    Object next = tokens.get(j);
    if (next instanceof PDFOperator)
    PDFOperator op = (PDFOperator) next;
    // Tj and TJ are the two operators that display strings in a PDF
    if (op.getOperation().equals("Tj"))
    // Tj takes one operator and that is the string
    // to display so lets update that operator
    COSString previous = (COSString) tokens.get(j - 1);
    System.out.println("COSString::"+previous);
    String string = previous.getString();
    string = string.replaceFirst("@loanamount", "5,00,000");
    //Word you want to change. Currently this code changes word "Solr" to "Solr123"
    previous.reset();
    previous.append(string.getBytes());
    PDStream updatedStream = new PDStream(doc);
    OutputStream out = updatedStream.createOutputStream();
    ContentStreamWriter tokenWriter = new ContentStreamWriter(out);
    tokenWriter.writeTokens(tokens);
    System.out.println("updatedStream::"+updatedStream.getInputStreamAsString());
    page.setContents(updatedStream);
    //setItem(COSName.CONTENTS,updatedStream);
    doc.save("D:/DOCS/loanamt_filled.pdf"); //Output file name
    sample content in pdf:
    Dear ABC,
    Your loan amount @loanamount is approved.
    Regards,
    DEF
    Output:Your loan amount is approved.
    I m getting empty spaces instead of @loanamount
    Could anyone help me out ?
    Please suggest me java open source api to replace caption or content in existing pdf.
    Thanks in advance...

    Tom
    To answer your original question, I know of now easy way of processing your clips and replacing the existing ones already edited.
    If I have this right you have your sequence fully edited?
    There is a workaround, messy and time consuming but it will not spoil the video element of the sequence.
    Process: -
    Drag the audio for each clip so that it is on a track with space at either end of it.
    Unlink each clip.
    For every audio clip extend each audio's head and tail
    Then use the edit in Audition link
    The clips are individually processed
    Then you can go back adjust the head and tail to what you want and fade out and in as you wish.
    I'd manually fade each clip rather than add an audio transition
    Take care not to alter the video clips at any time or you will go out of sync
    Hope this helps
    Col

  • Filename when dl PDF Blobs

    I have an APEX app that stores PDFs and RTF file in my DB as BLOBS. Users click on links and download these files. I use a DB procedure to build the http header for dl of the blob. (I think I got it from the APEX help section).
    Everything works except for the file name of the PDF blobs. I still get the file but the file name is always the name of my DB schema.pdf. The filename var is set correctly in the DB, same datatype as the RTF file.
    Same results if you left or right -> save target as click. RTF works. PDF works but odd filename.
    As anyone heard of an issue like this? Thanks for any help.
    Here are my two procedures:
    PDF (filename problem is here)
    create or replace PROCEDURE download_contractpdf(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
         -- Assuming your application's numeric ID is 122, set g_flow_id to
         -- that value, otherwise change the value as required.
         HTMLDB_APPLICATION.G_FLOW_ID := 122;
         IF NOT wwv_flow_custom_auth_std.is_session_valid then
         -- display this message or a custom message.
         htp.p('Unauthorized access - file will not be retrieved.');
         -- You can do whatever else you need to here to log the
         -- unauthorized access attempt, get the requestor's
         -- IP address, send email, etc.
         RETURN;
         END IF;
    SELECT 'application/pdf', PDFFILE, PDFFILENAME,DBMS_LOB.GETLENGTH(PDFFILE)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM ES_GENERATION_Q_STAFFAUG
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the PDFFILENAME will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; PDFFILENAME="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_contractpdf;
    RTF (this works)
    create or replace PROCEDURE download_contractrtf(p_file in number) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(2000);
    Lob_loc BLOB;
    BEGIN
         -- Assuming your application's numeric ID is 122, set g_flow_id to
         -- that value, otherwise change the value as required.
         HTMLDB_APPLICATION.G_FLOW_ID := 122;
         IF NOT wwv_flow_custom_auth_std.is_session_valid then
         -- display this message or a custom message.
         htp.p('Unauthorized access - file will not be retrieved.');
         -- You can do whatever else you need to here to log the
         -- unauthorized access attempt, get the requestor's
         -- IP address, send email, etc.
         RETURN;
         END IF;
    SELECT 'application/msword', RTFFILE, RTFFILENAME,DBMS_LOB.GETLENGTH(RTFFILE)
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM ES_GENERATION_Q_STAFFAUG
    WHERE id = p_file;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( nvl(v_mime,'application/octet'), FALSE );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||substr(v_file_name,instr(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    end download_contractrtf;

    Hi Regis,
    You have put this thread as answered.
    I have the same problem, can you tell me how you fixed this problem?
    thanks!
    KR,
    Micha

  • How to index a gzipped pdf blob

    Hi,
    I already have a TAR logged on this but if anyone knows how to do this, I would greatly appreciate any tips.
    I have our PDF documents stored in BLOB's in our DB but they are stored in gzipped format for significant space savings. I have developed two oracle functions; "gzip" and "gunzip", which are wrappers to java classes loaded into the DB, that can do the gzip compression and uncompression on the fly. These functions
    accept BLOB's and return BLOB's. I use these functions to send the documents to client browsers, etc.
    Now, I want to index these PDF documents but have hit problems.
    Eg, suppose the table structure is; STREAM(STREAM_ID NUMBER, PDF_GZIPPED BLOB). I need to build an Oracle Text index on
    STREAM(unzip(PDF_GZIPPED)). Where the unzip function accepts a BLOB and returns a BLOB (the real PDF document).
    My original approach was to use the multicolumn datastore because context indexes using these datastores could be based on functions of the table columns rather than just table columns. Oracle support informed me that multicolumn datastores will only work for VARCHAR2 types (not BLOB's) so I can't use that.
    If anyone has experience in indexing table/column functions for BLOB's, I would be interested to hear how to go about it. Please remember our PDF BLOB's are gzipped, not just PDF documents dumped into BLOB's.
    Harris.

    Sorry, the "unzip" function should read "gunzip" in the previous post.
    Anyway, for those interested, I have found a temporary workaround but boy is it cludgy;
    1. Had to setup a USER_FILTER
    2. Wrote a shell script wrapper to ctxhx
    3. But ctxhx on 8.1.7.2 always failed (unsure at this stage)
    4. So, it calls ctxhx under a previous version of Oracle;
    Here is the code;
    exec ctx_ddl.drop_preference('unzip_filter');
    exec ctx_ddl.create_preference('unzip_filter','USER_FILTER');
    exec ctx_ddl.set_attribute('unzip_filter', 'COMMAND', 'unzip_inso');
    exec ctx_ddl.drop_preference('pdf_lexer');
    exec ctx_ddl.create_preference('pdf_lexer', 'BASIC_LEXER');
    exec ctx_ddl.set_attribute('pdf_lexer', 'printjoins', '_-');
    drop index cas_stream_blob_ctx_i;
    create index cas_stream_blob_ctx_i
    on cas.stream_blob(pdf_gzipped)
    indextype is ctxsys.context
    parameters('filter UNZIP_FILTER lexer PDF_LEXER');
    exec ctx_ddl.sync_index('cas_stream_blob_ctx_i');
    Here is the source of unzip_inso;
    #!/bin/ksh
    test $# -lt 2 && return
    TMP_DIR=/tmp
    TMP_FILE=${TMP_DIR}/ora_gunzip_$$
    /usr/bin/gunzip -cf $1 > ${TMP_FILE} &&
    OUTFILE=$2
    shift 2
    #$ORACLE_HOME/ctx/bin/ctxhx ${TMP_FILE} ${OUTFILE} $*
    # 8.1.6 workaround
    export ORACLE_HOME=/product/oracle/8.1.6
    export LD_LIBRARY_PATH=$ORACLE_HOME/ctx/lib:$LD_LIBRARY_PATH
    export LD_LIBRARY_PATH_64=$ORACLE_HOME/ctx/lib64:$LD_LIBRARY_PATH_64
    ${ORACLE_HOME}/ctx/bin/ctxhx ${TMP_FILE} ${OUTFILE} $*
    rm -f ${TMP_FILE}
    It works - but very ugly.
    Still seeking a better solution - since I have the gzip utilities
    already loaded in the DB.

  • Looking for a way to find out the x,y coordinates of a string inside a PDF

    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.

    vedmack wrote:
    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.AFAIK, a string of text does not have an (x,y) location inside a PDF file. The location is exists on your screen, and will differ whenever you adjust the resolution of it. Text can have a location when it's stored as an image though, but than it's really the location of a certain number of pixels (not necessarily a string!).

  • Help required- Searching Particular string in column

    Hi,
    I have a table by name temp and 2 values in the table. I'm using LIKE caluse to search a string. I'm getting output for some particular string. Please correct the below query for me.
    I have given a table/data reference for you:
    Create table temp(col1 varchar2(255));
    insert into temp values ('Test_Scale_High');
    1 row inserted
    insert into temp values ('Test_Scale_High');
    1 row inserted
    commit;
    select * from temp;
    col1
    Test_Scale_High
    Test_Scale High
    select * from temp where upper(col1) like '%TEST_SCALE%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_H%';
    No Row Selected
    Thanks,
    Santhosh.S

    santhosh.shivaram wrote:
    select * from temp;
    col1
    Test_Scale_High
    Test_Scale High
    select * from temp where upper(col1) like '%TEST_SCALE%';
    COL1
    Test_Scale_High
    Test_Scale High
    select * from temp WHERE UPPER(COL1) LIKE '%TEST_SCALE_%';
    COL1
    Test_Scale_High
    Test_Scale High
    If I understand your requirement correctly you need to escape the Wild Card '_'
    Hope the following code helps:
    SQL> set feedback on;
    SQL> SELECT * FROM TEMP
      2  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE%'
      4  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE\_%' ESCAPE '\'
      4  /
    COL1
    Test_Scale_High
    1 row selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE_H%'
      4  /
    COL1
    Test_Scale_High
    Test_Scale High
    2 rows selected.
    SQL> SELECT *
      2    FROM temp
      3   WHERE UPPER (col1) LIKE '%TEST_SCALE\_H%' ESCAPE '\'
      4  /
    COL1
    Test_Scale_High
    1 row selected.
    SQL>Regards,
    Jo
    Edited by: Joice John : Added 2 Sample Codes

  • Search for content within a PDF

    Is it possible to search for content within a PDF across a mapped drive?

    Yes. Use Edit>Advanced search. Choose All PDF Documents in and choose the mapped drive.
    They have to be searchable PDF's of course...

  • Search a string with in some file and get the name of file

    i want to search a string in some files that are in a given directory and return the name of file having searched string.I am doing this with grep command as given below
    import java.io.*;
    public class linux_java {
    public static void main(String[] args) {
    try {
    String command = "find . | xargs grep -l Resolv /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG/*.txt";
    final Process process = Runtime.getRuntime().exec(command);
    OutputStream os= process.getOutputStream();
    System.out.println("out put stream= " +os);
    PrintStream stdIn = new PrintStream(new BufferedOutputStream(process.getOutputStream()), true);
    System.out.println("Return code = " + stdIn);
    } catch (Exception e) {
    e.printStackTrace();
    i dont know how to get the name of file that are return by the execution of command through process object. Please send the code for the same

    thanks for your suggestion....
    i change the code but now it is giving error as /usr/bin/find incomplete syntax....but i am giving the right syntax....
    please confirm whether the syntax is correct...
    import java.io.*;
    import java.util.*;
    public class linux_java {
    public static void main(String[] args) {
    try {
    //String command = "ls -alt";
    String command = "find /data2/opt/jakarta-tomcat-4.1.24/webapps/Oa/BOG -type f -exec grep -sl 'Aggarwal' {} \\; 2>/dev/null";
    ///grep -l System test/*java
    System.out.println(" the command is"+command);
    final Process process = Runtime.getRuntime().exec(command);
    InputStream is = process.getErrorStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line="";
    System.out.println(" the BufferedReader is"+br.readLine());
    while ((line = br.readLine()) != null) {
    System.out.println(" the files are"+line);
    } catch (Exception e) {
    e.printStackTrace();
    }

  • How to search a string from the database?

    how to search a string from the database? starting with some character

    If you're trying to do this in a SELECT, you can use the LIKE verb in your WHERE clause.
    Here's an Example
      SELECT obj_name FROM tadir
        INTO prog
        WHERE pgmid = 'R3TR'
          AND object = 'PROG'
          AND obj_name LIKE 'Z%'.
    In this case it will select every row that obj_name starts with Z. 
    If you wanted to find every row that the field obj_name contains say... 'WIN'  you use LIKE '%WIN%'.
    Edited by: Paul Chapman on Apr 22, 2008 12:32 PM

  • How to display PDF BLOB file within Forms

    Hi All:
    I just want to know if is it possible to display PDF blob file within the forms. Currently I use webutil to open pdf in browser. This time I need to display it in forms, so that upon scrolling, the user can view the pdf images of that particular record.
    TIA

    Hello,
    <p>Did you see this Java Bean ?</p>
    Francois

Maybe you are looking for