How to append content in begining of text file?

i want to append content in the begining of text file.
(usually append flag will append content in end of the file)
is there any class in java support this need?
if there is no class for this...anybody can give logic to implement
venu

Duplicate post
http://forum.java.sun.com/thread.jspa?threadID=577639

Similar Messages

  • How to get summary columns in delimited text file

    How to get summary columns in delimited text file
    I am trying to generate a delimited text file output with delimited_hdr = no.The report is a Group above report with summary columns at the bottom.In the text file the headers are not getting repeated & thats ok.The problem is the summary data is getting repeated for each row of data.Is there a way where i will get all the data & summary data will get displayed only once.I have to import the delimited text file in excel spreadsheet.

    Sorry there were a typos :
    When I used desformat=DELIMITEDDATA with desttype=FILE, I get error "unknown printer driver DELIMITEDDATA". When you look for help, DELIMITED is not even listed as one of the values for DESTFORMAT. But if you scroll down and look for DELIMITER it says , this works only in conjuction with DESTFORMAT=DELIMITED !!!!!!??!! This is in 9i.
    Has this thing worked for anybody ? Can anyone please tell if they were able to suppress the sumary columns or the parent columns of a master-detail data for that matter ?

  • How to read contents of more than 2 files.

    hi all
    help me.
    How to read contents of more than 2 files.
    For reading a file contents we uses normally FileInputStream
    For reading two file contents we uses normally SequenceInputStream
    But which class we have to use for reading contents of more than 2 files at a time
    thanks in advance.

    SequenceInputStream can be used for reading any number of input streams (not at once, but one after the other).
    This involves making an Enumeration that returns the input streams you want to read. Depending on what you want to do, it might be just as easy to read them one after another.
    Or consider making a Vector of your input streams and using its elements() method. Like this:(untested)Vector<InputStream> inVec = new Vector<InputStream>();
    inVec.add(new FileInputStream("foo.dat"));
    inVec.add(new FileInputStream("bar.dat"));
    inVec.add(new FileInputStream("baz.dat"));
    // later...
    SequenceInputStream in = new SequenceInputStream(inVec.elements());

  • How to append contents to an existing file contents at the end of file?

    Hi all
    I am Kiran, working with LV8.0  FDS
    I find difficulty while trying to add new file contents(some messages)  to an existing file at the end /begining of a file.
    Whenever i try to do that,it is replacing the previous contents,but i dont need that. i want the contents to be appended.
    Plz suggest me.
    thanks & regards
           kiran

    Hi Kiran,
    yes, I can attach a screenshot
    (open file, set file position to end, write text, close file)
    Message Edited by GerdW on 08-16-2007 03:19 PM
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    append.png ‏2 KB

  • How to append contents of a local object to dynamic internal table ?

    Dear ABAP-Specialists,
    i am trying to append contents of a local object to a dynamic table. The most relevant lines are the ones written in bold
    I guess the append is the problem due to the reason that a unknown format has to be assigned to a fixed format somehow.
    +METHOD wddomodifyview .+
      +DATA lo_ui_root                TYPE REF TO  if_wd_view_element.+
      +DATA lo_container              TYPE REF TO  cl_wd_uielement_container.+
      +DATA lo_table                  TYPE REF TO  cl_wd_table.+
      +DATA lo_table_column           TYPE REF TO  cl_wd_table_column.+
      +DATA lv_tabname                TYPE         tabname.+
      +DATA lt_output                 TYPE TABLE OF sychar512.+
      +DATA lo_data TYPE REF TO data.+
      +DATA:+
        +lo_node_output_data                    TYPE REF TO if_wd_context_node,+
        +lo_node_table_list                     TYPE REF TO if_wd_context_node,+
        +lo_node_differences                    TYPE REF TO if_wd_context_node,+
        +lo_node_output                         TYPE REF TO if_wd_context_node,+
        +lt_all_elem_differences                TYPE        wdr_context_element_set,+
        +lo_elem_table_list                     TYPE REF TO if_wd_context_element,+
        +lo_elem_differences                    TYPE REF TO if_wd_context_element,+
        +ls_differences                         TYPE        if_table_differences=>element_differences,+
        +lt_differences                         TYPE STANDARD TABLE OF if_table_differences=>element_differences.+
      +FIELD-SYMBOLS:+
                     +<ls_output> TYPE ANY,+
                     +<lt_output> TYPE ANY TABLE.+
    +     ....+
        +*CREATE DATA lo_data TYPE TABLE OF (lv_tabname).*+
        +*ASSIGN lo_data->* TO <lt_output>.*+
        +*LOOP AT lt_differences INTO ls_differences.*+
    +**      APPEND ls_differences-ct_line TO lo_data->*.*+
        +*ENDLOOP.*     ....+
    +ENDMETHOD.+
    Thanks a lot in advance for your Ideas.
    Best regards
    Carsten Klatt
    Please post in the correct forum and use code tags to format your code
    Edited by: Rob Burbank on Oct 1, 2010 1:27 PM

    This might help - you should not reference the data reference directly:
    DATA: lt_t001 TYPE TABLE OF t001,
          ls_t001 TYPE t001.
    DATA: lr_dref    TYPE REF TO data.
    DATA: lv_tabname TYPE tabname.
    FIELD-SYMBOLS: <lfs>      TYPE table,
                   <lfs_line> TYPE ANY.
    lv_tabname = 'T001'.
    TRY.
        CREATE DATA lr_dref TYPE TABLE OF (lv_tabname).
        ASSIGN lr_dref->* TO <lfs>.
      CATCH cx_sy_create_data_error.
    *     Do something
    ENDTRY.
    SELECT * FROM t001 INTO TABLE lt_t001.
    LOOP AT lt_t001 INTO ls_t001.
      ASSIGN ls_t001 TO <lfs_line>.
      APPEND <lfs_line> TO <lfs>.
    ENDLOOP.

  • Append a line to a text file

    hi,
    I'm using Oracle 11g.
    I'm storing text files in XML DB and accessing them using FTP, pl/sql and Java.
    Sometimes this files are huge, and all I need is to append a line.
    Is there any way to do this, without reading the full content of the file, using PL/SQL? Or Java?
    Thanks for all the help you can give me.

    procedure writeDebug(P_LOG_MESSAGE VARCHAR2)
    as
    pragma autonomous_transaction;
    V_LOG_CONTENT CLOB;
    V_LOG_BUFFER blob;
    V_SOURCE_OFFSET integer := 1;
    V_TARGET_OFFSET integer := 1;
    V_WARNING integer;
    V_LANG_CONTEXT integer := 0;
    V_DEBUG_CONTENT blob;
    begin
    createDebugOutputFile;
    update RESOURCE_VIEW
    set RES = updateXML(RES,'/Resource/DisplayName/text()',extractValue(RES,'/Resource/DisplayName/text()'))
    where equals_path(RES,G_DEBUG_OUTPUT_FILE) = 1;
    select extractValue(RES,'/Resource/XMLLob')
    into V_DEBUG_CONTENT
    from RESOURCE_VIEW
    where equals_path(RES,G_DEBUG_OUTPUT_FILE) = 1;
    V_LOG_CONTENT := chr(13) || chr(10) || to_char(systimestamp,'YYYY-MM-DD"T"HH24:MI:SS.FF') || ' : ' || P_LOG_MESSAGE;
    dbms_lob.createTemporary(V_LOG_BUFFER,true);
    dbms_lob.convertToBlob(V_LOG_BUFFER,V_LOG_CONTENT,dbms_lob.getLength(V_LOG_CONTENT),V_SOURCE_OFFSET,V_TARGET_OFFSET,nls_charset_id('AL32UTF8'),V_LANG_CONTEXT,V_WARNING);
    dbms_lob.freeTemporary(V_LOG_CONTENT);
    dbms_lob.open(V_DEBUG_CONTENT,dbms_lob.lob_readwrite);
    dbms_lob.append(V_DEBUG_CONTENT,V_LOG_BUFFER);
    dbms_lob.close(V_DEBUG_CONTENT);
    dbms_lob.freeTemporary(V_LOG_BUFFER);
    commit;
    end;

  • Removing useless contents of an unsorted text file in excel 2013

    hi friends
    i am new to excel & there is an urgent need for me, that's why i pose this question which may appear simple.
    in my server i have redirected the output of a command help into a text file (c:\myhelp.txt)
    i have pasted some initial lines of that text file here:
    The following is a list of unattend parameters for promotion (default values are enclosed in <>):
    /AllowDomainControllerReinstall:{Yes | <No> | NoAndNoPromptEither}
    Specifies whether to continue installing this domain controller despite that a domain controller account with the same name is detected. Specify Yes only if you are sure that the account is no longer in use.
    /AllowDomainReinstall:{Yes | <No> | NoAndNoPromptEither}
    Specifies whether an existing domain is recreated.
    /ApplicationPartitionsToReplicate:""
    Specifies application partitions to be replicated in the format of "partition1" "partition2". If * is specified, all application partitions will be replicated.
    now i need to import this text file into excel 2013 so that i be able to remove comments & descriptions ( in fact anything except command switches, which their characteristics is that they begin with an
    slash & there is no space between their words).
    in other words i need to preserver strings which start with an slash.
    for example i need only the following strings remain in the file:
    /AllowDomainControllerReinstall:
    /AllowDomainReinstall:
    /ApplicationPartitionsToReplicate:
    so that then i be able to export that file & then execute my command & specify the path to this answer file (c:\myhelp.txt)
    how can i achieve this in excel?
    can i easily do the entire process when importing that file into excel, using importing options? if not, how can i do that after opened in excel?
    in the following screenshots i have shown what import options i used when importing this help file into excel & the result:
    really thanks in advanced, i really need this help.

    Hi John,
    Bit unclear on your requirment.
    Let me put it this way.
    1.You are running some command which generates output c:\myhelp.txt in multiple lines.
    2. You want to reformat the contents of c:\myhelp.txt so that only parameter name remains in each line, without the values.
    3. Reuse the updated c:\myhelp-clean.txt file into some other script\command.
    I can help you with quick excel formatting on point 2.
    Points noted:- the parameter are seperated from the rest of the data by ":" colon
    Hence once data is opened in excel, use Text-Col ->Delimited->Other-> Type : (colon) as the delimitor.
    This will result in only the 1st column with the long text in some rows and /parameters seperated
    Then Select all the data in the first column, Filter->Drop Down, Text Filters->Begins with-> /
    Only text with the parameters remain, as desc rows don't have / in beginning.
    Copy this and save it in another text file for re-use.
    Regards,
    Satyajit
    Please“Vote As Helpful”
    if you find my contribution useful or “MarkAs Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.
    Hi Satyajit.
    worked that's Great !
    thank you very very much for your great help
    best regards  ;-)

  • How To download a idoc to a text file

    Hi Gurus,
    Can anyone let me know how to download  idoc to  a text  file (Local).
    Thanks  in advance
    B S B.

    Hi,
    Check the code below...
    Reads an existing Idoc and dispays the contents in a spreadsheet format
    REPORT Z_DISPLAY_IDOC_AND_DATA line-size 275.
    * This tool reads an existing Idoc and dispays the contents in a       *
    * spreadsheet format. The spreadsheet (MS-EXCEL) will be automatically *
    * created if D_EXCEL = 'X'.                                            *
    data: idoc_control like EDIDC,
          NUMBER_OF_DATA_RECORDS like sy-dbcnt,
          NUMBER_OF_STATUS_RECORDS like sy-dbcnt,
          INT_EDIDS like edids occurs 0 with header line,
          INT_EDIDD like edidd occurs 0 with header line.
    TYPE-POOLS :  LEDID.
    data: STRUCT_TYPE TYPE  LEDID_STRUCT_TYPE ,
          IDOC_STRUCT TYPE  LEDID_T_IDOC_STRUCT,
          SEGMENTS TYPE  LEDID_T_SEGMENT,
          SEGMENT_STRUCT TYPE  LEDID_T_SEGMENT_STRUCT,
          excel_tab(2000) occurs 0 with header line.
    parameter: DOCNUM like edidc-docnum obligatory, ""Idoc Number
               sap_rel like SY-SAPRL default SY-SAPRL obligatory,
               pi_ver like EDI_VERREC-VERSION default '3' obligatory,
               d_excel as checkbox default 'X'. ""Download ?
    start-of-selection.
      perform read_idoc.
      perform process_idoc.
      if d_excel = 'X'.
        perform download_to_excel.
      endif.
    end-of-selection.
    FORM read_idoc.
      CALL FUNCTION 'IDOC_READ_COMPLETELY'
           EXPORTING
                DOCUMENT_NUMBER          = docnum
           IMPORTING
                IDOC_CONTROL             = idoc_control
                NUMBER_OF_DATA_RECORDS   = NUMBER_OF_DATA_RECORDS
                NUMBER_OF_STATUS_RECORDS = NUMBER_OF_STATUS_RECORDS
           TABLES
                INT_EDIDS                = INT_EDIDS
                INT_EDIDD                = INT_EDIDD
           EXCEPTIONS
                DOCUMENT_NOT_EXIST       = 1
                DOCUMENT_NUMBER_INVALID  = 2
                OTHERS                   = 3.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "" read_idoc
    FORM process_idoc.
      perform read_idoc_structure.
      perform display_data_records.
    ENDFORM.                    "" process_idoc
    FORM display_data_records.
      data: PE_seg_HEADER like EDI_SAPI01,
            segname like EDI_IAPI12-SEGMENTTYP,
            prev_segname like EDI_IAPI12-SEGMENTTYP value ' ',
            pt_fields2 like EDI_IAPI12 occurs 0 with header line,
            PT_FVALUES2 like EDI_IAPI14 occurs 0 with header line,
            byte_first type i,
            byte_last type i,
            field_val(50),
            tmp_str(15),
            tmp_str3(15),
            seg_repeats type i value 0,
            tmp_str2(15),
            tab_cr(1) type x value '09',
            tot_ctr type i value 0,
            ctr type i value 0,
            msg(40) type c.
      data: IDOC_STRUCT_wa TYPE  LEDID_IDOC_STRUCT.
      sort int_edidd by segnum.
      describe table int_edidd lines tot_ctr.
      loop at int_edidd.
        move int_edidd-segnam to segname.
        clear msg.
        concatenate 'Reading segment ' segname
                    into msg separated by space.
        if tot_ctr <> 0.
          ctr = ( 100 * sy-tabix ) / tot_ctr.
        endif.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
             EXPORTING
                  PERCENTAGE = ctr
                  TEXT       = msg.
        add 1 to seg_repeats.
        clear tmp_str2.
        if int_edidd-segnam <> prev_segname.
          seg_repeats = 1.
          clear: pe_seg_header, pt_fields2, pt_fvalues2.
          refresh: pt_fields2, pt_fvalues2.
          CALL FUNCTION 'SEGMENT_READ_COMPLETE'
               EXPORTING
                    PI_SEGTYP                 = segname
                    PI_RELEASE                = sap_rel
                    PI_VERSION                = pi_ver
               IMPORTING
                    PE_HEADER                 = pe_seg_header
               TABLES
                    PT_FIELDS                 = pt_fields2
                    PT_FVALUES                = pt_fvalues2
               EXCEPTIONS
                    SEGMENT_UNKNOWN           = 1
                    SEGMENT_STRUCTURE_UNKNOWN = 2
                    OTHERS                    = 3.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE 'I' NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          prev_segname = int_edidd-segnam.
        endif.
        read table idoc_struct into idoc_struct_wa with key
                               segment_type = int_edidd-segnam.
        if sy-subrc = 0.
          IF IDOC_STRUCT_WA-SYNTAX_ATTRIB-MUSTFL = 'X'.
            TMP_STR = 'Mandatory'.                  ""Mandatory
          ELSE.
            TMP_STR = 'Optional'.                  ""Optional
          ENDIF.
          if IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-QUALIFIER = 'X'.
            tmp_str3 = 'Qualified'.
          else.
            tmp_str3 = 'Non-Qualified'.
          endif.
          shift IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
                                     left deleting leading '0'.
          move seg_repeats to tmp_str2.
          condense: IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX, tmp_str2.
          concatenate tmp_str2 'of'  IDOC_STRUCT_wa-SYNTAX_ATTRIB-OCCMAX
              into tmp_str2 separated by space.
          write :/ IDOC_STRUCT_wa-SEGMENT_TYPE,
               tmp_str,
               TMP_STR3,
               tmp_str2,
               IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL,
               IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast,
               IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP.
          if d_excel = 'X'.
            concatenate 'Segment Name' tab_cr
                        'Mand / Opt ' tab_cr
                        'Qual / non-Qual' tab_cr
                        'Seq of Max' tab_cr
                        'Level' tab_cr
                        'Owner' tab_cr
                        'Description'
                        into excel_tab.
            append excel_tab.
            concatenate IDOC_STRUCT_wa-SEGMENT_TYPE tab_cr
                  tmp_str tab_cr
                  TMP_STR3 tab_cr
                  tmp_str2 tab_cr
                  IDOC_STRUCT_wa-SYNTAX_ATTRIB-HLEVEL tab_cr
                  IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-plast tab_cr
                  IDOC_STRUCT_wa-SEGMENT_TYPE_ATTRIB-DESCRP
                  into excel_tab.
            append excel_tab.
            concatenate tab_cr
                        'Field Nma' tab_cr
                        'Type' tab_cr
                        'Length' tab_cr
                        'Byte From' tab_cr
                        'Byte To' tab_cr
                        'Description' tab_cr
                        'Value' tab_cr
                        'Qualifier Meaning'
                        into excel_tab.
            append excel_tab.
          endif.
        endif.
        sort pt_fields2 by field_pos.
        byte_first = 0.
        loop at pt_fields2.
          clear: field_val.
          byte_last = pt_fields2-EXTLEN.
          write int_edidd-sdata+byte_first(byte_last) to
                field_val left-justified.
          shift pt_fields2-EXTLEN left deleting leading '0'.
          shift pt_fields2-byte_first left deleting leading '0'.
          shift pt_fields2-byte_last left deleting leading '0'.
          write:/ '   ', pt_fields2-fieldname,
                  pt_fields2-datatype,
                  pt_fields2-EXTLEN,
                  pt_fields2-byte_first ,
                  pt_fields2-byte_last,
                  pt_fields2-descrp,
                  field_val.
          read table pt_fvalues2 with key fieldname = pt_fields2-fieldname
                        fldvalue_l = field_val.
          add byte_last to byte_first.
          if sy-subrc = 0.
            write : pt_fvalues2-descrp.
          else.
            clear pt_fvalues2-descrp.
          endif.
          if d_excel = 'X'.
            concatenate tab_cr pt_fields2-fieldname tab_cr
                    pt_fields2-datatype tab_cr
                    pt_fields2-EXTLEN tab_cr
                    pt_fields2-byte_first tab_cr
                    pt_fields2-byte_last tab_cr
                    pt_fields2-descrp tab_cr
                    field_val tab_cr
                    pt_fvalues2-descrp
                    into excel_tab.
            append excel_tab.
          endif.
        endloop.
      endloop.
    ENDFORM.                    "" display_data_records
    FORM read_idoc_structure.
      data: idoctype type LEDID_IDOCTYPE.
      if not idoc_control-cimtyp is initial.
        STRUCT_TYPE = 'E'. ""Extended
        idoctype = idoc_control-cimtyp.
      else.
        STRUCT_TYPE = 'B'. ""Basic
        idoctype = idoc_control-idoctp.
      endif.
      CALL FUNCTION 'IDOC_TYPE_COMPLETE_READ'
           EXPORTING
                RELEASE              = sap_rel
                STRUCT_TYPE          = STRUCT_TYPE
                IDOCTYPE             = idoctype
                VERSION              = pi_ver
    *       IMPORTING
    *            IDOC_TYPE            = idoctype
           TABLES
                IDOC_STRUCT          = idoc_struct
                SEGMENTS             = segments
                SEGMENT_STRUCT       = segment_struct
           EXCEPTIONS
                IDOCTYPE_UNKNOWN     = 1
                IDOCSTRUCT_UNKNOWN   = 2
                SEGMENT_DATA_MISSING = 3
                ILLEGAL_STRUCT_TYPE  = 4
                OTHERS               = 5.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "" read_idoc_structure
    FORM download_to_excel.
      data: name like RLGRAP-FILENAME.
      shift docnum left deleting leading '0'.
      concatenate docnum '-' idoc_control-idoctp '.xls'
                  into name.
      CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
       EXPORTING
         DATA_NAME                 = name
         DATA_TYPE                 = 'ASC'
         WAIT                      = ' '
       TABLES
         DATA_TAB                  = excel_tab
       EXCEPTIONS
         NO_BATCH                  = 1
         EXCEL_NOT_INSTALLED       = 2
         WRONG_VERSION             = 3
         INTERNAL_ERROR            = 4
         INVALID_TYPE              = 5
         CANCELLED                 = 6
         DOWNLOAD_ERROR            = 7
         OTHERS                    = 8
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    "" download_to_excel
    Cheers
    VJ

  • HOW TO WRITE AND READ FROM A TEXT FILE???

    How can I read from a text file and then display the contents in a JTextArea??????
    Also how can I write the contents of a JTextArea to a text file.
    Extra Question::::::: Is it possible to write records to a text file. If you have not idea what I am talking about then ignore it.
    Manny thanks,
    your help is much appreciated though you don't know it!

    Do 3 things.
    -- Look through the API at the java.io package.
    -- Search previous posts for "read write from text file"
    -- Search java.sun.com for information on the java.io package.
    That should clear just about everything up. If you have more specific problems, feel free to come back and post them.

  • How do i read a context of text file within Dynamic Page of portal ?

    Dear sir,
    I have a text file in client computer. I hope i can transfer the context words of this text file to oracle database. How do i coding this script in dynamic page of portal?
    Can Oaracle 9ias script read and draw the context of a document. Thank you ver much!
    Ghia Liu

    Great questions, Rik, and I understand how this might seem bizarre. Here's the story... these 2500 files were authored with a built-in authoring tool of our current knowledge management system. This KMS is about to be replaced with a new one and because the new KMS needs content within the <head> tag instead of where it was in the <body> tag and redefined as meta data, I repuposed the content in those files using Dreamweaver and regular expressions.  However, the one remaining <h3> and <p> content is in the middle of the newly tagged meta data and it must be moved from the <head> area and into the <body> area.
    Because these were authored in the built-in KMS authoring tool, there is no style sheet and no, we do not manage our content with a CMS.
    You are correct, if the <h3> and <p> were at the end of the data, I could simply move the </head> and <body> tags, but unfortunately that is not the case.  They are consistenly in the same place in all 2500 files, but in the middle of the data. Following is an example:
    <html>
    <head>
    <title>Title here</title>
    <meta name="XYZ" content="Something here...">
    <h3> Blah blah</h3> <p>More blah blah</p>
    <meta name="123" content="More somthing here">
    <meta name="456" content="More somthing here">
    </head>
    <body>
    </body>
    </html>
    Again, I can find the block using a regular expression <h3>(.*?)</p>, but dont know what to do after that.
    I've been told that perl or grep might do the needed task, but that requires outside resources and I have no budget for that.
    Any suggestions are greatly appreciated.
    thanks,
    Rick

  • UNICODE Byte Order Marker at beginning of text files

    Hi,
    I'm running in to problems when reading text from a number of text files, some of which are plain US-ASCII text and others which are also plain US-ASCII content but contain a UNICODE UTF-8 Byte Order Mark at the beginning of the file i.e. the bytes 0xEF 0xBB 0xBF.
    I open each file using standard :
    InputStream fis = new FileInputStream(fileName);
    Reader fileReader = new InputStreamReader(fis);
    However, in those cases where a BOM is present, the first 3 characters of my stream are the BOM above which I would have expected to have been automatically stripped. When I set the encoding in the InputStreamReader I still get a single garbage character, whereas when I perform above with UTF-16 I get only the files chars as expected.
    Do I need to open this file as a byte stream and check the BOM myself and then derive the type of encoding I should be opening the file with? And if so, for UTF-8 I also then must discard the first 3 bytes?
    Please help as I don't want to have to do this if possible and I hope someone can understand my problem.
    My JVM environment is 1.4.2 on XP.
    Many THanks,
    Henry

    Probably not. Some of the Unicode encoding types... the list is here:
    http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html
    support the BOM, so you'd only need to know that it's UnicodeBig or UnicodeLittle or whatever it really is.
    Of course, if you don't know what it is, that is a problem. You can probably assume the BOM bytes are actually that, but technically, you can't generally infer any particular encoding type by just reading the file. I mean, who's to say that a file is UTF-8 encoded or ISO8859-1? Yes, if it is UTF-8, and it includes chars that are of multi-byte sets (Chinese, for example), then many characters, if read as ISO8859-1, would look on screen like gibberish. But from the standpoint of reading a file at the character level, Java doesn't care and can't know.
    So to really know, you would either have to know ahead of time what the encoding is, or do some analysis of the data to see if it's likely 1 or the other, which is probably hard to do cuz it would require some sort of natural language knowledge.

  • How to download a ABAP report to text file

    Hi Experts,
      I want to save a ABAP report to a local file in my PC (*txt format).  Since it uses a lot of includes, I have to download those ones too..   Is there is quickway to save the main program and all it's subprograms to a text file ?
    Regards
    Shibu

    Hi,
    Try this report, it will solve u r problem,
    TABLES:TRDIR.
    SELECT-OPTIONS: PGMNAME FOR TRDIR-NAME.
    CONSTANTS:  LINESIZE value 2048.
    PARAMETERS:
                 HEADING AS CHECKBOX DEFAULT 'X',
                 FGROUP AS CHECKBOX,
                 USER LIKE TRDIR-CNAM DEFAULT '*',
                 DOWNLOAD AS CHECKBOX default 'X',
                 pa_TEXTP AS CHECKBOX,
                 DOWNDIR(80) DEFAULT 'C:\temp\',
                 chg_date(8) default '19000101',
                 chg_time(6) default '000000'.
                PGMNAME like TRDIR-NAME.
    DATA:
         W_TEXT(128),
         W_FILENAME(128),
         W_PROGRAM_LOW(8),
         W_PROGRAM_HIGH(8).
    DATA:
        _texttab type textpool,
         texttab type standard table of textpool initial size 0
           with header line,
        BEGIN OF TEXTTAB OCCURS 0,
                        ID(1),
                        KEY(8),
                        ENTRY(70),
        END         OF TEXTTAB,
         BEGIN OF ABAPTAB OCCURS 500,
                        LINE(72),
                          line(LINESIZE),
         END         OF ABAPTAB,
         BEGIN OF TRTAB OCCURS 0,
                         NAME LIKE         TRDIR-NAME,
                         ENTRY LIKE       TEXTTAB-ENTRY,
                         CDAT LIKE         TRDIR-CDAT,
                         UDAT LIKE         TRDIR-UDAT,
         END                 OF TRTAB,
         BEGIN OF TRFTAB OCCURS 0,
                         NAME LIKE         TRDIR-NAME,
                         ENTRY LIKE       TEXTTAB-ENTRY,
                         CDAT LIKE         TRDIR-CDAT,
                         UDAT LIKE         TRDIR-UDAT,
         END OF TRFTAB.
    START-OF-SELECTION.
         IF FGROUP = ' '.
                         PERFORM LOAD_TRDIR_PROGRAM.
                         PERFORM PROCESS_PROGRAM.
         ELSE.
                         PERFORM LOAD_TRDIR_FGROUP.
                         PERFORM PROCESS_FGROUP.
         ENDIF.
    *&                                         form load_trdir_program.
    FORM LOAD_TRDIR_PROGRAM.
         SELECT * FROM TRDIR
                         WHERE NAME IN PGMNAME
                           and sdate >= chg_date
                           and stime >= chg_time.
                         IF USER <> '*'.
                                         CHECK TRDIR-UNAM = USER OR
                                         TRDIR-CNAM = USER.
                         ENDIF.
                         CLEAR: TEXTTAB.
                         REFRESH: TEXTTAB.
                         CLEAR: TRTAB.
                         READ TEXTPOOL TRDIR-NAME INTO TEXTTAB LANGUAGE 'E'.
                         IF SY-SUBRC = 0.
                                         READ TABLE TEXTTAB WITH KEY 'R'.
                                         MOVE TEXTTAB-ENTRY TO TRTAB-ENTRY.
                         ENDIF.
                         MOVE TRDIR-NAME         TO TRTAB-NAME.
                         MOVE TRDIR-CDAT         TO TRTAB-CDAT.
                         MOVE TRDIR-UDAT         TO TRTAB-UDAT.
                         APPEND TRTAB.
                         CLEAR: TEXTTAB.
         ENDSELECT.
    ENDFORM.     "         load_trdir_program
    *&                                         Form load_trdir_fgroup
    FORM LOAD_TRDIR_FGROUP.
         SELECT * FROM TRDIR
                         WHERE NAME BETWEEN 'SAPLYYYY' AND 'SAPLZZZZ'.
                         CHECK TRDIR-UNAM = USER OR TRDIR-CNAM = USER.
                         CLEAR: TEXTTAB.
                         CLEAR: TRTAB.
                         REFRESH: TEXTTAB.
                         READ TEXTPOOL TRDIR-NAME INTO TEXTTAB LANGUAGE 'E'.
                         IF SY-SUBRC = 0.
                                         READ TABLE TEXTTAB WITH KEY 'R'.
                                         MOVE TEXTTAB-ENTRY TO TRTAB-ENTRY.
                         ENDIF.
                         MOVE TRDIR-NAME TO TRTAB-NAME.
                         MOVE TRDIR-CDAT TO TRTAB-CDAT.
                         MOVE TRDIR-UDAT TO TRTAB-UDAT.
                         APPEND TRTAB.
                         CLEAR: TEXTTAB.
         ENDSELECT.
         LOOP AT TRTAB.
                         MOVE-CORRESPONDING TRTAB TO TRFTAB.
                         APPEND TRFTAB.
                         MOVE TRTAB-NAME+3(5) TO W_PROGRAM_LOW.
                         MOVE '%' TO W_PROGRAM_LOW+5(1).
                         MOVE TRTAB-NAME+3(5) TO W_PROGRAM_HIGH.
                         MOVE 'MMMMMMMM' TO W_PROGRAM_HIGH.
                         SELECT * FROM TRDIR
                                         WHERE NAME LIKE W_PROGRAM_LOW.
    *where name between w_program_low and w_program_high.
                                         CHECK TRDIR-NAME+5(1) <> '$'.
                                         CHECK TRDIR-NAME(5) =
                                         TRTAB-NAME+3(5).
                                         READ TEXTPOOL TRDIR-NAME INTO
                                         TEXTTAB LANGUAGE 'E'.
                                         READ TABLE TEXTTAB WITH KEY 'R'.
                                         MOVE TEXTTAB-ENTRY TO TRFTAB-ENTRY.
                                         MOVE TRDIR-NAME TO TRFTAB-NAME.
                                         MOVE TRDIR-CDAT TO TRFTAB-CDAT.
                                         MOVE TRDIR-UDAT TO TRFTAB-UDAT.
                                         APPEND TRFTAB.
                         ENDSELECT.
         ENDLOOP.
    ENDFORM.     " load_trdir_fgroup.
                                                    FORM PROCESS_PROGRAM
    FORM PROCESS_PROGRAM.
         LOOP AT TRTAB.
                         READ REPORT TRTAB-NAME INTO ABAPTAB.
                         IF DOWNLOAD = 'X'.
                             PERFORM DOWNLOAD_PROGRAMS USING TRTAB-NAME.
                         ELSE.
                             PERFORM LIST_PROGRAMS USING TRTAB-NAME.
                         ENDIF.
                         IF pa_TEXTP = 'X'.
                              READ TEXTPOOL TRTAB-NAME INTO TEXTTAB LANGUAGE
                              'E'.
                                 IF SY-SUBRC = 0 AND DOWNLOAD = 'X'.
                                     PERFORM DOWNLOAD_TEXTPOOL USING
                                     TRTAB-NAME.
                                 ENDIF.
                                     LOOP AT TEXTTAB.
                                         WRITE:/
                                         TEXTTAB-ID,
                                         TEXTTAB-KEY,
                                         TEXTTAB-ENTRY.
                                     ENDLOOP.
                         ENDIF.
         ENDLOOP.
    ENDFORM.
                                                    FORM PROCESS_fgroup
    FORM PROCESS_FGROUP.
         LOOP AT TRFTAB.
                         READ REPORT TRFTAB-NAME INTO ABAPTAB.
                         IF DOWNLOAD = 'X'.
                             PERFORM DOWNLOAD_PROGRAMS USING TRFTAB-NAME.
                         ELSE.
                             PERFORM LIST_PROGRAMS         USING TRFTAB-NAME
                         ENDIF.
                         IF pa_TEXTP = 'X'.
                             READ TEXTPOOL TRFTAB-NAME INTO TEXTTAB LANGUAGE
                             'E'.
                                 IF SY-SUBRC = 0 AND DOWNLOAD = 'X'.
                                      PERFORM DOWNLOAD_TEXTPOOL USING
                                      TRFTAB-NAME.
                                      LOOP AT TEXTTAB.
                                               WRITE:/
                                               TEXTTAB-ID,
                                               TEXTTAB-KEY,
                                               TEXTTAB-ENTRY.
                                      ENDLOOP.
                                 ENDIF.
                         ENDIF.
         ENDLOOP.
    ENDFORM.
    *&                                       Form DOWNLOAD_PROGRAMS
    FORM DOWNLOAD_PROGRAMS USING NAME.
         W_TEXT = 'Downloading'.
         W_TEXT+15(8) = NAME.
         CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
              EXPORTING
                    TEXT = W_TEXT
              EXCEPTIONS
                    OTHERS = 1.
         clear w_filename.
         MOVE DOWNDIR TO W_FILENAME(80).
        MOVE NAME TO W_FILENAME+20(8).
        MOVE '.txt' TO W_FILENAME+28(4).
        CONDENSE W_FILENAME NO-GAPS.
         concatenate w_filename name '.doc' into w_filename.
         condense w_filename no-gaps.
         CALL FUNCTION 'WS_DOWNLOAD'
              EXPORTING
                   FILENAME = W_FILENAME
                   FILETYPE = 'ASC'
              TABLES
                   DATA_TAB = ABAPTAB
              EXCEPTIONS
                   FILE_OPEN_ERROR = 1
                   FILE_WRITE_ERROR = 2
                   INVALID_FILESIZE = 3
                   INVALID_TABLE_WIDTH = 4
                   INVALID_TYPE = 5
                   NO_BATCH = 6
                   UNKNOWN_ERROR = 7
                   OTHERS = 8.
    ENDFORM.   " DOWNLOAD_PROGRAMS
    *&                                         Form LIST_PROGRAMS
    FORM LIST_PROGRAMS         USING NAME.
         LOOP AT ABAPTAB.
                         WRITE:/ NAME, ABAPTAB-LINE.
         ENDLOOP.
    ENDFORM.     " LIST_PROGRAMS
    *&                                       Form DOWNLOAD_TEXTPOOL
    FORM DOWNLOAD_TEXTPOOL                 USING NAME.
         W_TEXT = 'Textpool...'.
         W_TEXT+15(8) = NAME.
         CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
                EXPORTING
                        TEXT = W_TEXT
                EXCEPTIONS
                        OTHERS = 1.
         MOVE DOWNDIR TO W_FILENAME(80).
         MOVE TRTAB-NAME TO W_FILENAME+20(8).
         MOVE '.tpl' TO W_FILENAME+28(4).
         CONDENSE W_FILENAME NO-GAPS.
         CALL FUNCTION 'WS_DOWNLOAD'
              EXPORTING
                   FILENAME = W_FILENAME
                   FILETYPE = 'ASC'
              TABLES
                   DATA_TAB = TEXTTAB
              EXCEPTIONS
                   FILE_OPEN_ERROR = 1
                   FILE_WRITE_ERROR = 2
                   INVALID_FILESIZE = 3
                   INVALID_TABLE_WIDTH = 4
                   INVALID_TYPE = 5
                   NO_BATCH = 6
                   UNKNOWN_ERROR = 7
                    OTHERS = 8.
    ENDFORM.             " DOWNLOAD_TEXTPOOL
    TOP-OF-PAGE.
         IF HEADING = 'X'.
            Place your heading here:
                    call function 'Z_WRITE_HEADER_FOOTER'
                            exporting
                              type = 'H'
                            exceptions
                              others = 1.
            skip 1.
         ENDIF.
    Regards
    Nilesh

  • ZipOutputStream appends characters to beginning of zipped file?

    Hi and thanks in advance for any help!
    I am trying to zip Excel files using ZipOutputStream class. I can open the Excel files fine before I zip. Then I run my program to zip. It seems to work. I use WinZip to unzip and when I try and open unzipped file in Excel, Excel says it does not recognize format. Looking at unzipped file in text editor, about 15 wierd characters and nulls are now appended to the beginning of my Excel file that are not in the original. If I delete them in the text editor, Excel can open.
    Here is my zip code:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(baos);
    ArrayList fileNames = new ArrayList();
    fileNames.add ("91PSAG0Jak.csv");
    fileNames.add ("91I9F60K62.csv");
    // Compress the files
    for (int i=0; i<2; i++) {
    String filename = String.valueOf(fileNames.get(i));
    byte[] file = DatabaseUtilities.downloadFile("pdfstoragedir", filename);
    // Add ZIP entry to output stream.
    zos.putNextEntry(new ZipEntry(filename));
    ObjectOutputStream oos = new ObjectOutputStream (zos);
    oos.writeObject(file);
    oos.flush();
    // Complete the entry
    zos.closeEntry();
    //Complete the ZIP file
    zos.close();
    byte[] zipFile = baos.toByteArray();
    DatabaseUtilities.uploadFile("pdfstoragedir", "zipOutput.zip", zipFile);
    FileOutputStream fos = new FileOutputStream("C:\\zipOutput.zip");
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    bos.write(zipFile, 0, zipFile.length);

    Thanks, I got it I think, I can write my byte[] directly to the zipOutputStream:
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(baos);
    ArrayList fileNames = new ArrayList();
    fileNames.add ("8aCeOH0Fba.zip");
    fileNames.add ("8da6S40H4e.zip");
    // Compress the files
    for (int i=0; i<2; i++) {
    String filename = String.valueOf(fileNames.get(i));
    byte[] file = DatabaseUtilities.downloadFile("pdfstoragedir", filename);
    // Add ZIP entry to output stream.
    zos.putNextEntry(new ZipEntry(filename));
    zos.write(file);
    // Complete the entry
    zos.closeEntry();
    //Complete the ZIP file
    zos.close();
    byte[] zipFile = baos.toByteArray();
    DatabaseUtilities.uploadFile("pdfstoragedir", "zipOutput.zip", zipFile);
    FileOutputStream fos = new FileOutputStream("C:\\zipOutput.zip");
    BufferedOutputStream bos = new BufferedOutputStream(fos);
    bos.write(zipFile, 0, zipFile.length);

  • How Open And Print Proc C Genrated Text File Based Report ON Browser

    Dear Sir
    I have my old 6i forms from which i runs some Pro*c programmers with the help of HOST() command ,and then that generates a normal text file as a resultant report like file name "kha10"
    which i can easily open with any text client ,,,
    now what i want is that, to open this file on browser like web Report on my forms 10g like report builder 10g
    can anyone help me as it will be a gr8 help otherwise i would have to develop approx 100 reports.....
    any solution or any technique plzz help me

    bro my work is almost done apart from this virtual directory , how to make a virtual directory so that is dosent comes under
    http://........../form/
    i mean where to put my
    <virtual-directory virtual-path="/procrepo" real-path="c:\" />
    as my original file looks like bellow
    <?xml version="1.0"?>
    <!DOCTYPE orion-web-app PUBLIC "-//ORACLE//DTD OC4J Web Application 9.04//EN" "http://xmlns.oracle.com/ias/dtds/orion-web-9_04.dtd">
    <orion-web-app
         deployment-version="10.1.2.0.2"
         jsp-cache-directory="./persistence"
         temporary-directory="./temp"
         servlet-webdir="/servlet/"
    >
    <context-param-mapping name="configFileName">D:\DevSuiteHome_1/forms/server/formsweb.cfg</context-param-mapping>
         <virtual-directory virtual-path="/html" real-path="D:\DevSuiteHome_1/tools/web/html" />
         <virtual-directory virtual-path="/java" real-path="D:\DevSuiteHome_1/forms/java" />
         <virtual-directory virtual-path="/webutil" real-path="D:\DevSuiteHome_1/forms/webutil" />
         <virtual-directory virtual-path="/jinitiator" real-path="D:\DevSuiteHome_1/jinit" />
         <session-tracking cookies="disabled" />
    <!-- Uncomment this element to control web application class loader behavior.
    <web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true" />
    -->
    <security-role-mapping name="administrators">
    </security-role-mapping>
    </orion-web-app>
    plzzzzzzzzzzz help

  • How to add header and fooder in text file

    Hi,
    i have created simple application for generate report from database into text file.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.
    the below text are needs to be print in the header
    name of the table :
    Recorder type :
    file creation time:
    the below text are needs to be print in the footer
    Recorder Number:
    Record Type;
    the actual code is
                           pst = con.prepareStatement("select REQUEST, DOMAIN_NAME, TRUNC(DATE_OF_CONFIGURATION) AS dateofConfig  FROM employee where id=300");
                               rs = pst.executeQuery();
                            while (rs.next()) {
                                 request = rs.getString("REQUEST");
                                    domain_name = rs.getString("DOMAIN_NAME");
                                    dateofconfig = rs.getString("dateofConfig");
                                    System.out.println(request + " " + domain_name + " " + dateofconfig);
                                   data.add(request + " " + domain_name + " " + dateofconfig);
                            System.out.println("before calling method");
                            writeToFile(data, "c:/Employee.txt");
                            System.out.println("file created successfull");
                            rs.close();
                            pst.close();
           private static void writeToFile(List list, String path) {
                    BufferedWriter out = null;
                    try {
                            File file = new File(path);
                            out = new BufferedWriter(new FileWriter(file, true));
                            for (Object obj : list) {
                                String s=  obj.toString(); 
                                 out.write(s);
                                    out.newLine();
                            out.close();
                    } catch (IOException e) {
    }Thanks
    Jasmin
    Edited by: user13836688 on Mar 21, 2011 4:06 AM
    Edited by: user13836688 on Mar 21, 2011 4:07 AM
    Edited by: user13836688 on Mar 21, 2011 4:08 AM

    user13836688 wrote:
    i have created simple application for generate report from database into text file.First off, when posting code, use &#91;code]...&#91;/code]. or '' tags, not '<code>'.
    But i need to add header and fooder in text file. I dont know is there any API for adding these.
    Can anyone help me to create header and fooder in text file.Well you plainly have the code to write the file contents; and furthermore your report seems to be contained in a List called 'data'. Why not just add the header and footer lines to it? I'd also suggest making 'data' a LinkedList. That way you can add the header afterwards with no performance hit, just in case the information it contains isn't available at the start of your report loop.
    Winston                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for