How to read a file content from portal

Hi experts,
I have a file (xml or xlsx), which i have kept in D drive.
then using GUI_UPLOAD, i have read file content into internal table. then i am proceeding furthur.
but in real, my file will be in portal (means https:\\in.xyz.com\........\TEST.XML
in this case i can not use GUI_UPLOAD.
can any one suggest how can i achieve above. Thanks.
Regards,
Venkata Prasad

Hi venkata
try this code below
tables: znks_exceldb.
types: begin of wa_input,
       emp_id type string,
       name type string,
       middle type string,
       last_name type string,
       address type string,
       acc_num type string,
       mobile type string,
end of wa_input.
data: gt_intern type kcde_intern.
data:gwa_intern type kcde_intern_struc.
data gt_input type table of wa_input.
data gwa_input like line of gt_input.
data it_tab type table of znks_exceldb.
data it_wa like line of it_tab.
constants c_seprator type c value ','.
parameters ex_file type localfile obligatory.
at selection-screen on value-request for ex_file.
  call function 'F4_FILENAME'
* EXPORTING
*   PROGRAM_NAME        = SYST-CPROG
*   DYNPRO_NUMBER       = SYST-DYNNR
*   FIELD_NAME          = ' '
   importing
     file_name           = ex_file.
start-of-selection.
  perform readfile using ex_file.
  perform insert.
  perform display.
form readfile using ex_file type localfile.
  data:lv_filename type rlgrap-filename.
  data: lv_index type i.
  field-symbols: <> type any.
  lv_filename = ex_file.
  call function 'KCD_CSV_FILE_TO_INTERN_CONVERT'
    exporting
      i_filename      = lv_filename
      i_separator     = c_seprator
    tables
      e_intern        = gt_intern
    exceptions
      upload_csv      = 1
      upload_filetype = 2
      others          = 3.
  if sy-subrc <> 0.
* Implement suitable error handling here
  endif.
  loop at gt_intern into gwa_intern.
    move gwa_intern-col to lv_index.
    assign component lv_index of structure gwa_input to <>.
    move:gwa_intern-value to <>.
    at end of row.
      append gwa_input  to gt_input.
      clear gwa_input.
    endat.
  endloop.
endform.
form insert.
  loop at gt_input into gwa_input.
    it_wa-emp_id = gwa_input-emp_id.
    it_wa-name = gwa_input-name.
    it_wa-middle = gwa_input-middle.
    it_wa-last_name = gwa_input-last_name.
    it_wa-address = gwa_input-address.
    it_wa-mobile = gwa_input-mobile.
    it_wa-acc_num = gwa_input-acc_num.
    append it_wa to it_tab.
  endloop.
  insert znks_exceldb from table it_tab accepting duplicate keys.
endform.
form display.
  loop at gt_input into gwa_input.
    write :/ gwa_input-emp_id,
             gwa_input-name,
             gwa_input-middle,
             gwa_input-last_name,
             gwa_input-address,
              gwa_input-mobile,
              gwa_input-acc_num .
  endloop.
endform.
Regards
Niraj Sinha

Similar Messages

  • How to read text file content in portal application?

    Hi,
    How do we read text file content in portal application?
    Can anyone forward the code to do do?
    Regards,
    Anagha

    Check the code below. This help you to know how to read the text file content line by line. You can display as you require.
    IUser user = WPUMFactory.getServiceUserFactory().getServiceUser("cmadmin_service");
    IResourceContext resourceContext = new ResourceContext(user);
    String filePath = "/documents/....";
    RID rid = RID.getRID(filePath);
    IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
    InputStream inputStream = resource.getContent().getInputStream();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
    String line = reader.readLine();
    while(line!=null) {
          line = reader.readLine();
         //You can append in string buffer to get file content as string object//
    Regards,
    Yoga

  • How to read trace file content

    Hi,
    DB :11.2
    How to read trace file content.It's only for ORACLE SUPPORT?
    calling         
    call
    entry           
    argument values in hex
    location        
    type
    point           
    (? means dubious value)
    ksedst()+31     
    call
    ksedst1()       
    000000000 ? 000000001 ?
    7FFF19B98CA0 ? 7FFF19B98D00 ?
    7FFF19B98C40 ? 000000000 ?
    ksedmp()+610    
    call
    ksedst()        
    000000000 ? 000000001 ?
    7FFF19B98CA0 ? 7FFF19B98D00 ?
    7FFF19B98C40 ? 000000000 ?
    ksfdmp()+21     
    call
    ksedmp()        
    000000003 ? 000000001 ?
    7FFF19B98CA0 ? 7FFF19B98D00 ?
    7FFF19B98C40 ? 000000000 ?
    kgerinv()+161   
    call
    ksfdmp()        
    000000003 ? 000000001 ?
    7FFF19B98CA0 ? 7FFF19B98D00 ?
    7FFF19B98C40 ? 000000000 ?
    kgeasnmierr()+163
    call
    kgerinv()       
    0069107E0 ? 011F80370 ?
    7FFF19B98D00 ? 7FFF19B98C40 ?
    000000000 ? 000000000 ?
    kssmov()+502    
    call
    kgeasnmierr()   
    0069107E0 ? 011F80370 ?
    7FFF19B98D00 ? 7FFF19B98C40 ?
    000000029 ? 0D3F1C600 ?
    kfncInitSlavePool()  call
    kssmov()        
    0D3F1C5D0 ? 000000000 ?
    +203                                          
    7FFF19B98D00 ? 7FFF19B98C40 ?
    000000029 ? 0D3F1C600 ?
    kfncWorkMsgAlloc()+  call
    kfncInitSlavePool()  0D3F1C5D0 ? 000000000 ?
    83                                            
    7FFF19B98D00 ? 7FFF19B98C40 ?
    000000029 ? 0D3F1C600 ?
    kfncFileUnidentify(  call
    kfncWorkMsgAlloc()   0D3F1C5D0 ? 7FFF19B99AD0 ?
    )+635                                         
    7FFF19B98D00 ? 7FFF19B98C40 ?
    000000029 ? 0D3F1C600 ?
    kffmRequestFree()+1  call
    kfncFileUnidentify(  7FFF19B99BC8 ? 7FFF19B99BC0 ?
    Br,
    Raj

    One needs to know the meaning of the kernel functions and their working within the oracle database. I guess, oracle support can do the analysis more easily as they have access to the software code  as well necessary tools to interpret these internal routines.
    Aman....

  • How to extract original file contents from content server

    Hi,
    1)How can we extract original file contents from the content server (which in our case is SAP database itself)...
    2)What exactly is PHIO_ID and LOIO_ID?
    Thanks and regards,
    Santhosh Kumar U.P

    Hi,
    concerning your first question - please decribe, what you are trying to do.
    Question 2:
    LOIO_ID is the ID of the Logical Information Object. A LOIO is not a real document, but kind of a virtual document, a containerfor all "real" versions of a document. A PHIO (physical info object) is a real document.
    you can read more at http://sercie.sap.com/Kpro
    Kind regards,
    Carl

  • How to print PDF file content from ABAP in background?

    Hi,
    Is it possible to print PDF file content from ABAP in background?
    I have some PDF content which I need to print it, these PDF files are generated outside the SAP.
    Please have you any suggestions?
    Thank you
    Tomas

    <b><u>Solution:</u></b><br>
    <br>
    The target output device must support PDF print, this is only one limitation.<br>
    <br>
    REPORT  z_print_pdf.
    TYPE-POOLS: abap, srmgs.
    PARAMETERS: p_prnds LIKE tsp01-rqdest OBLIGATORY DEFAULT 'LOCL',
                p_fname TYPE file_table-filename OBLIGATORY LOWER CASE,
                p_ncopi TYPE rspocopies OBLIGATORY DEFAULT '1',
                p_immed AS CHECKBOX.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
      DATA: lv_rc     TYPE i,
            lv_filter TYPE string.
      DATA: lt_files TYPE filetable.
      FIELD-SYMBOLS: <fs_file> LIKE LINE OF lt_files.
      CONCATENATE 'PDF (*.pdf)|*.pdf|' cl_gui_frontend_services=>filetype_all INTO lv_filter.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          file_filter             = lv_filter
        CHANGING
          file_table              = lt_files
          rc                      = lv_rc
        EXCEPTIONS
          OTHERS                  = 1.
      IF sy-subrc NE 0 AND lv_rc EQ 0.
        MESSAGE 'Error' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      READ TABLE lt_files ASSIGNING <fs_file> INDEX 1.
      IF sy-subrc EQ 0.
        p_fname = <fs_file>-filename.
      ENDIF.
    AT SELECTION-SCREEN.
      DATA: lv_name   TYPE string,
            lv_result TYPE boolean.
      lv_name = p_fname.
      CALL METHOD cl_gui_frontend_services=>file_exist
        EXPORTING
          file                 = lv_name
        RECEIVING
          result               = lv_result
        EXCEPTIONS
          OTHERS               = 1.
      IF sy-subrc NE 0.
        MESSAGE 'Bad file!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      IF lv_result NE abap_true.
        MESSAGE 'Bad file!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
    START-OF-SELECTION.
    END-OF-SELECTION.
      PERFORM process.
    FORM process.
      DATA: lv_name     TYPE string,
            lv_size     TYPE i,
            lv_data     TYPE xstring,
            lv_retcode  TYPE i.
      DATA: lt_file TYPE srmgs_bin_content.
      lv_name = p_fname.
      CALL METHOD cl_gui_frontend_services=>gui_upload
        EXPORTING
          filename                = lv_name
          filetype                = 'BIN'
        IMPORTING
          filelength              = lv_size
        CHANGING
          data_tab                = lt_file
        EXCEPTIONS
          OTHERS                  = 1.
      IF sy-subrc NE 0.
        MESSAGE 'Read file error!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
        EXPORTING
          input_length = lv_size
        IMPORTING
          buffer       = lv_data
        TABLES
          binary_tab   = lt_file
        EXCEPTIONS
          failed       = 1
          OTHERS       = 2.
      IF sy-subrc NE 0.
        MESSAGE 'Binary conversion error!' TYPE 'E' DISPLAY LIKE 'S'.
      ENDIF.
      PERFORM print USING p_prnds lv_data CHANGING lv_retcode.
      IF lv_retcode EQ 0.
        WRITE: / 'Print OK' COLOR COL_POSITIVE.
      ELSE.
        WRITE: / 'Print ERROR' COLOR COL_NEGATIVE.
      ENDIF.
    ENDFORM.                    " PROCESS
    FORM print USING    iv_prndst  TYPE rspopname
                        iv_content TYPE xstring
               CHANGING ev_retcode TYPE i.
      DATA: lv_handle    TYPE sy-tabix,
            lv_spoolid   TYPE rspoid,
            lv_partname  TYPE adspart,
            lv_globaldir TYPE text1024,
            lv_dstfile   TYPE text1024,
            lv_filesize  TYPE i,
            lv_pages     TYPE i.
      CLEAR: ev_retcode.
      CALL FUNCTION 'ADS_SR_OPEN'
        EXPORTING
          dest            = iv_prndst
          doctype         = 'ADSP'
          copies          = p_ncopi
          immediate_print = p_immed
          auto_delete     = 'X'
        IMPORTING
          handle          = lv_handle
          spoolid         = lv_spoolid
          partname        = lv_partname
        EXCEPTIONS
          OTHERS          = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ADS_GET_PATH'
        IMPORTING
          ads_path = lv_globaldir.
      CONCATENATE lv_globaldir '/' lv_partname '.pdf' INTO lv_dstfile.
      OPEN DATASET lv_dstfile FOR OUTPUT IN BINARY MODE.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      TRANSFER iv_content TO lv_dstfile.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CLOSE DATASET lv_dstfile.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ZBAP_RM_PDF_GET_PAGES'
        EXPORTING
          iv_content = iv_content
        IMPORTING
          ev_pages   = lv_pages.
      lv_filesize = XSTRLEN( iv_content ).
      CALL FUNCTION 'ADS_SR_CONFIRM'
        EXPORTING
          handle   = lv_handle
          partname = lv_partname
          size     = lv_filesize
          pages    = lv_pages
          no_pdf   = ' '
        EXCEPTIONS
          OTHERS   = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
      CALL FUNCTION 'ADS_SR_CLOSE'
        EXPORTING
          handle = lv_handle
        EXCEPTIONS
          OTHERS = 1.
      IF sy-subrc NE 0.
        ev_retcode = 4.
        RETURN.
      ENDIF.
    ENDFORM.                    " PRINT

  • How to read entire file content in one XML tag?

    Hi,
    How can I read entire file content in one XML tag?
    What specifications do I need to specify in Sender adapter?
    regards,
    Anirudh.

    Hi Chirag,
    I am reading a flat file for File to Idoc scenario.
    Target Idoc is nested which can not be populated with graphical mapping.
    see below post for more detail.
    [Mapping flat XML to nested IDOC using node functions |Mapping flat XML to nested IDOC using node functions;
    The problem here is I'm not able to identify when to insert context change for child which is repeating for a repeating parent.
    Solution therefore, I think is reading entire flat structure in one node and then use UDF to populated intermediate target with proper nesting.
    Thats why I need to read entire XML.
    regards,
    Anirudh.

  • How to view the file content from the directory? getting Error:ORA-21560

    SQL> create directory READ_LOB_DIR as 'D:\Prj\Comm\Data';
    CREATE OR REPLACE Procedure READ_FILE_LOB IS
    -- Input Directory as specified in create directory
    l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
    -- Input File which is read word by word
    l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
    -- Separator Character between words is a BLANK (ascii = 32)
    l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
    -- Character at the end of the file is NEWLINE (ascii = 10)
    l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
    -- Pointer to the BFILE
    l_loc BFILE;
    -- Current position in the file (file begins at position 1)
    l_pos NUMBER := 1;
    -- Amount of characters have been read
    l_sum BINARY_INTEGER := 0;
    -- Read Buffer
    l_buf VARCHAR2(500);
    -- End of the current word which will be read
    l_end NUMBER;
    -- Return value
    l_ret BOOLEAN := FALSE;
    BEGIN
    -- Mapping the physical file with the pointer to the BFILE
    l_loc := BFILENAME(l_dir, l_fil);
    -- Check if the file exists
    l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
    IF (l_ret) THEN
    dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
    ' exists');
    -- Open the file in READ_ONLY mode
    DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
    LOOP
    -- Calculate the end of the current word
    l_end := DBMS_LOB.INSTR(l_loc, l_seb, l_pos, 1);
    -- Process end-of-file
    IF (l_end = 0) THEN
    l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
    l_sum := l_end - l_pos - 1;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    EXIT;
    END IF;
    -- Read until end-of-file
    l_sum := l_end - l_pos;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    l_pos := l_pos + l_sum + 1;
    END LOOP;
    DBMS_LOB.CLOSE(l_loc);
    ELSE
    dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
    ' does not exist');
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('Error:' || SQLERRM);
    DBMS_LOB.CLOSE(l_loc);
    END;
    The Text file content is...
    Copyright 1996,2001 Oracle Corporation.     All Rights Reserved
    This file contains installation instructions for installing the
    Oracle8 ODBC Driver software.
    It is divided into four parts:
    o Part I: Summary of systems supported by Oracle8 ODBC client
    software
    Lists the platforms on which the Oracle8 ODBC Client software can
    be installed.
    o Part II: Oracle8 ODBC Driver software.
    Describes the files, and installation prerequisites for the Oracle8
    ODBC driver software.
    o Part III: Exploding the kit onto your system
    Describes how to explode the kit onto your system hard drive.
    o Part IV: Installation Instructions
    Describes how to install the Oracle8 ODBC driver.
    Part I: Systems supported by the Oracle8 client software
    You can install the ODBC client software on any of the following systems:
    o Windows 2000
    o Windows NT X86
    o Windows 95
    o Windows 98
    The Oracle8 ODBC Driver provides support for ODBC connections
    from Windows 2000, Windows NT, Windows 95, and Windows 98 systems
    to Oracle databases.
    o Part II: Oracle8 ODBC Driver software.
    Refer to the following files for information about the Oracle8 ODBC Driver:
    LICENSE.TXT - Oracle8 ODBC Driver License Agreement. Read carefully
    before installing and/or using this product. Enclosed in
    your software distribution kit.
    SQORA.HLP - A Window's Help file which is the primary reference
              manual for the Oracle8 ODBC Driver.
    ODBCRelnotes.WRI - The release notes for the Oracle8 ODBC Driver
    which contains information which may have not been
    included in the Help file.
    Installation Prerequisites
    See the Oracle8 ODBC Driver release notes (ODBCRelnotes.WRI),
    for a complete list of software products required and their versions.
    Time Required
    The installation of the Oracle8 ODBC Driver takes approximately 5
    minutes. The actual time may be shorter or longer, depending upon
    your hardware configuration.
    Disk Space Required
    The Oracle8 ODBC driver installation requires approximately 2
    megabytes of available storage space. The space required depends upon
    what files you already have installed. The installation procedure
    checks to see if you have enough available disk space. If you do not,
    the installation fails.
    Part III: Exploding the Kit onto your system
    Expand the self-extracting archive file onto your hard drive.
    C:\> ORA8174.EXE
    Part IV: Installation Instructions
    Oracle8 ODBC Driver 8.1.7.4.0
    This section assumes the following:
    1. MS Windows 2000, Windows NT, Windows 95 or Windows 98 is running.
    2. Oracle Universal Installer shipping with 8.1.7 has already been
    installed on your system.
    3. Part III has been completed.
    Software fixes:
    Refer to release notes (ODBCRelnotes.wri) for a complete list of
    Software fixes.
    Installation Instructions
    Once the self-extracting archive file ORA8174.EXE has been
    exploded it will create an installable directory structure
    onto your hard drive. Run the Oracle Universal Installer from
    your local drive.
    1. On the screen "File Locations" use the "Browse" button of
    the source path to choose the file 'products.jar' from the
    folder that ORA8174.EXE was extracted to. Choose 'Next'.
    2. You will receive a warning that some of the dependencies of
    this product are not found in the staging area. This warning
    is OK. The ODBC driver depends on the Net8 Client being already
    installed on the system. Answer 'Yes' to continue.
    Oracle is a registered trademark of Oracle Corporation.
    Microsoft, MS are registered trademarks of Microsoft Corporation.
    Microsoft Windows, Windows NT, Windows 95, Windows 98 and Open Database
    Connectivity are trademarks of Microsoft Corporation.
    All other trademarks and registered trademarks are the property
    of their respective owners.
    The output was...
    File testfile.txt in Directory READ_LOB_DIR exists
    Copyright
    1996,2001
    Oracle
    Corporation.     
    All
    Rights
    Reserved
    This
    file
    contains
    installation
    instructions
    for
    installing
    the
    Oracle8
    ODBC
    Driver
    software.
    It
    is
    divided
    into
    four
    parts:
    o
    Part
    I:
    Summary
    of
    systems
    supported
    by
    Oracle8
    ODBC
    client
    Error:ORA-21560: argument 2 is null, invalid, or out of range
    I want to diplay/view as per file content format from the file under that specified directory.
    Have any other method / any help or suggestions would be really appreciated.

    I changed the code like...
    CREATE OR REPLACE Procedure READ_FILE_LOB_tmp IS
    -- Input Directory as specified in create directory
    l_dir CONSTANT VARCHAR2(30) := 'READ_LOB_DIR';
    -- Input File which is read word by word
    l_fil CONSTANT VARCHAR2(30) := 'testfile.txt';
    -- Separator Character between words is a BLANK (ascii = 32)
    l_seb CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(32));
    -- Character at the end of the file is NEWLINE (ascii = 10)
    l_sen CONSTANT RAW(100) := UTL_RAW.CAST_TO_RAW(CHR(10));
    -- Pointer to the BFILE
    l_loc BFILE;
    -- Current position in the file (file begins at position 1)
    l_pos NUMBER := 1;
    -- Amount of characters have been read
    l_sum BINARY_INTEGER := 0;
    -- Read Buffer
    l_buf VARCHAR2(4000);
    -- End of the current word which will be read
    l_end NUMBER;
    -- Return value
    l_ret BOOLEAN := FALSE;
    BEGIN
    -- Mapping the physical file with the pointer to the BFILE
    l_loc := BFILENAME(l_dir, l_fil);
    -- Check if the file exists
    l_ret := DBMS_LOB.FILEEXISTS(l_loc) = 1;
    IF (l_ret) THEN
    dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
    ' exists');
    -- Open the file in READ_ONLY mode
    DBMS_LOB.OPEN(l_loc, DBMS_LOB.LOB_READONLY);
    LOOP
    -- Calculate the end of the current word
    l_end := DBMS_LOB.INSTR(l_loc, l_sen, l_pos, 1);
    -- Process end-of-file
    IF (l_end = 0) THEN
    EXIT;
    END IF;
    -- Read until end-of-file
    l_sum := l_end - l_pos;
    DBMS_LOB.READ(l_loc, l_sum, l_pos, l_buf);
    dbms_output.put_line(UTL_RAW.CAST_TO_VARCHAR2(l_buf));
    l_pos := l_pos + l_sum + 1;
    END LOOP;
    DBMS_LOB.CLOSE(l_loc);
    ELSE
    dbms_output.put_line('File ' || l_fil || ' in Directory ' || l_dir ||
    ' does not exist');
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line('Error:' || SQLERRM);
    DBMS_LOB.CLOSE(l_loc);
    END;
    Now its working fine with one addtional line...
    The file content is...
    This is My Content
    This is My Content
    This is My Content
    This is My Content
    This is My Content
    But The output was...
    File testfile.txt in Directory READ_LOB_DIR exists
    This is My Content
    This is My Content
    This is My Content
    This is My Content
    This is My Content
    here, i want to delete that additonal line...?

  • How to read a file just from middle?

    I want to read a file which has 200,000 lines. And I want to read it from 100,000, but I don't want to read it from begining. So I use LineNumberReader class, but it failed. The code:
    LineNumberReader lnr=new LineNumberReader(new InputStreamReader(src_lob.getBinaryStream()));
             lnr.setLineNumber(5);
             String line="";
             while((line=lnr.readLine())!=null)
                     System.out.println(line);
             } How to change the code???

    Random Access File will be good option I think
    filelength=RandomAccessFile.length();
    raf.seek(filelength/2);
    then read file characters

  • How to read a file starting from certain line number

    Hi there
    I need to read a large text file line by line. The user will have the ability to stop at any time and run the application to resume reading and processing. For example, if the user stops at line 350, next time when the user run the application, I want him to be able to start with line 351. I am using BufferedReader to read the file. What should I do enable to read the file starting certain line number? Each line in the text file is not equal in length, so I can not control by bytes ...
    Thanks!

    Since you can't count bytes, there's no way of knowing where to jump except actually reading trough all those preceding lines. (You don't have to store them, though.)
    for(int linenum=0, linenum<jumpTo; ++linenum) {
        reader.readLine();
    }

  • How to read a file content in a ordinary java program

    Please help me is there is any method is available to read the content of the file.I am asking in pure java not in the servlets.Guys please help me.I got structed here

    Reading a text file in the systems character encoding: use the class java.io.FileReader. You can wrap a BufferedReader around it to get better performance (and a simple way to read lines)
    Reading a text file in another character encoding: use FileInputStream and convert it to a reader with:
    InputStreamReader reader = new InputStreamReader(fileStream, encoding);
    where encoding is the character encoding as a String (like "Cp850" or "UTF-16LE"). Again, you can wrap a BufferedReader around that reader.
    Reading a binary file: open a FileInputStream to the file and just read the bytes from it. You can use BufferedInputStream for better performance and DataInputStream to get a simple way to read primitive types like double and char.
    Please help me is there is any method is available to
    read the content of the file.I am asking in pure java
    not in the servlets.Guys please help me.I got structed
    hereAren't servlets pure Java?

  • How to read a file content for editing?

    Now i am using FileInputStream to read its content by bytes. How do i read the content line by line as string so that i am able to do some editing using replace().

        public String load() throws FileNotFoundException, IOException {
             BufferedReader r = new BufferedReader(new FileReader(new File(this.getClass().getResource(filename).getPath())));
             String s = r.readLine();
             StringBuffer result = new StringBuffer();
             while (s != null) {
                  result.append(s + "\n");
                  s = r.readLine();
             r.close();
             return result.toString();

  • Reading RTF file content from JSP which stored in database as image format

    <%@page import="java.sql.*" %>
    <%@page import="java.net.*" %>
    <%@page import="java.io.*" %>
    <%@page import="java.*" %>
    <%@page import="javax.swing.*" %>
    <%@page import="javax.swing.text.*" %>
    <%@page import="javax.swing.text.rtf.*" %>
    <%
         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    Connection con=DriverManager.getConnection("jdbc:sqlserver://local:1433;databaseName=database;user=sa");
         Statement st=con.createStatement();
         ResultSet rs=st.executeQuery("select Document from docrev where UniqeId ='199207' ");//("select data from rtfdata");227317
         rs.next();
         byte bt[]=rs.getBytes(1);
         InputStream fi = new ByteArrayInputStream( bt );
         RTFEditorKit rtf = new RTFEditorKit();
         JEditorPane editor = new JEditorPane();
         editor.setEditorKit( rtf );
         rtf.read( fi, editor.getDocument(), 0 );
         Document d=editor.getDocument();
         String str=d.getText(0,d.getLength());
         /*OutputStream fo=new FileOutputStream("temp3.rtf");
         fo.write(str.getBytes());*/
    %>
    <html>
    <body>
    <p><textarea name=myarea style="background:#FFCC99" cols=100 rows=50><%=str%></textarea>
    </body>
    </html>
    Edited by: Santhu538 on Oct 23, 2007 10:16 PM
    Edited by: Santhu538 on Oct 23, 2007 10:25 PM
    Edited by: Santhu538 on Oct 23, 2007 10:26 PM

    Please use code tags while posting code. See the code button above the text area?
    It's a good practise not to mix jdbc code in your jsp (mvc and all that you see)
    Finally you'll have to quickly decide on your front end - jsp or swing. It looks like the former, but then with the code you have posted, the server is apt to pop up some windows prompting the user who has logged on (to the server) to choose the files for the client :)
    ram.

  • How to read xml node content from java[ urgent]

    My tag is
    <person1> a="hello">
    <person><first>Steve</first></person>
    </person1>
    I want if i read <person1> tag then it store its inner content in a string.
    i.e my output should be
    <person><first>Steve</first></person>

    Hi, parse the file using dom.then print out the root tag.you will have to strip the indentation this way.or you could use sax.

  • 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

  • How to read .xml file from embedded .swf(flash output) in captivate

    I have been trying to read .xml file from the .swf (Flash output) that is embedded within the captivate file but no luck yet . Please if anyone got any clue on how get this thing done using Action script 3.0 then let me know. I am using Adobe Captivate 5.5 at present and Flash CS 5.5.
    I am well aware about how to read .xml file through action script 3.0 in flash but when insert the same flash in captivate and publish nothing comes in captivate output. I would higly appreciate if anyone could help me out with that.
    Here is is graphical demonstration of my query :
    Message was edited by: captainmkv

    Hi Captainmkv,
    Does the information in this post cover what you're trying to do: http://forums.adobe.com/message/5081928#5081928
    Tristan,

Maybe you are looking for