How to fetch the perticular line of a internal Table

Hi Friends,
I am using Function Module  VC_I_GET_CONFIGURATION and I am passing the instance Number.
Now i am getting 18 records in my ITAB.Here from this ITAB i need only ATBEZ = RELAY TYPES & ATBEZ = CASE Records.Only for the mentioned conditions i require the records.
How Can i Proceed.Plz suggest.As CASE is the reserved word and Types also reserved Word.
Plz suggest.

Hi,
Thanks for ur Reply and Can i Use Read statement for the same. My requirement is ATBEZ = 'RELAY TYPES' AND 'CASE'.
While Printing in smart form for one item there will be only one Relay type.How can i proceed.
If i write LOOP AT ITAB WHERE ATBEZ = 'RELAY TYPES' or ATBEZ = ' CASE'.
2 records r coming and only the secong recored is appending.First Record will not append.
How can i do.
Plz suggest.

Similar Messages

  • How to fetch the SAP Standard Prog. built internal table into my_z_prog.?

    Hi Experts,
    Pls. let me know that,
    How to fetch the SAP Standard Prog. built internal table into my_z_prog.?
    For more explannation, pls. see my other thread with name of yestrday,
    SUBMIT RFGLBALANCE WITH selection criteria, then How to get resulted itab?
    thanq

    Hi
    Suppose RFGLBALANCE is your standard program and you have an internal table named I_RFGLBALANCE.
    And lets say your Z program name is Z_SRINIVAS.
    First find out the type of the internal table you want in your Z-program in the standard program. And declare an internal table of similar type in your Z-program.
    I hope you can do this much.
    Later wherever you are putting the below mentioned code.
    SUBMIT RFGLBALANCE WITH selection criteria
    Write the code which i have written.Obviously modify it to suit your requirement.
    Please show what is not working fine so that even anyone else can help you with the problem you are facing.
    Regards,
    Mayank

  • How to fetch the data from query to internal table ?

    Dear all ,
             I would like to fetch the query data(sq01) into my internal table ? is it possible to do that ?
    Best Regards,
    Carlos

    Hi
    Try this <b>RRW3_GET_QUERY_VIEW_DATA</b>
    Also, you can have a look at this...
    <a href="/people/durairaj.athavanraja/blog/2005/04/03/execute-bw-query-using-abap-part-ii Query results into Internal table</a>
    Regards
    Raj

  • How can I search the last line in an internal table?

    How can I search the last line in an internal table?
    With a describe?? If it is , how can I do that?
    Thanks!!

    Hi shilpa,
    it seems to be you are NEW to SDN. welcome. if you want to get solutions to your Questions, you have to post a NEW thread.dont use the existing thread to post your question.
    any way i am giving you the solution for your question
    LOOP AT ITAB WHERE F1 = <SOME VALUE>
                       F2 = <SOME VALUE>.
    ENDLOOP.
    IF SY-SUBRC = 0.
      ITAB WILL HAVE THE LAST RECORD which satisfying the given criteria in WHERE clause of LOOP.
      write itab <--this ITAB will have the last record.
    ENDIF.
    regards,
    Srikanth.
    Message was edited by: Srikanth Kidambi

  • How to get the field name of an internal table during runtime?

    How to get the field name of an internal table during runtime?

    Hi  Sudhir,
    Declare and Use Get Cursor Field in Your Prm to get the field Name of the Intenal Table
    Example Code:
        <b>  DATA: v_field(60).                        " Insert this code.
         GET CURSOR FIELD v_field.        " Insert this code.</b>
         <b>CHECK v_field = 'ITAB-KUNNR'.    " Insert this code. (or)
    Write: v_field.</b>
    Regards,
    Ramganesan K.

  • How to find number of lines in an internal table

    Dear all,
    how to find number of records present in an internal table.

    DESCRIBE TABLE
    Syntax
    DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
    Extras:
    1. ... KIND knd
    2. ... LINES lin
    3. ... OCCURS n
    Effect
    This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.
    In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.
    Notes
    For detailed information about an internal table, you should use the methods of RTTS of the DESCRIBE TABLE statement.
    Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
    Addition 1
    ... KIND knd
    Effect
    The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.
    Addition 2
    ... LINES lin
    Effect
    The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
    Note
    As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.
    Addition 3
    ... OCCURS n
    Effect
    The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.
    Example
    Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.
    TYPE-POOLS sydes.
    FORM sort_descending CHANGING itab TYPE ANY TABLE.
      DATA tabkind(1) TYPE c.
      DESCRIBE TABLE itab KIND tabkind.
      IF tabkind = sydes_kind-standard OR
         tabkind = sydes_kind-hashed.
        SORT itab DESCENDING.
      ELSEIF tabkind = sydes_kind-sorted.
        MESSAGE '...' TYPE 'E'.
      ELSE.
        MESSAGE '...' TYPE 'E'.
      ENDIF.
    ENDFORM.
    DESCRIBE FIELD INTO
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Syntax
    DESCRIBE FIELD dobj INTO td.
    Effect
    All characteristics of the field f, its components , sub-components etc. are displayed in the field td (type description). td has to be of the type SYDES_DESC, defined in Type Group SYDES. Because of this, the type group SYDES must be integrated into the ABAP-program with a TYPE-POOLS statement .
    The structure SYDES_DESC has two table-type components TYPES and NAMES:
    In TYPES, the tree structure of the type belonging to f is displayed. The components of a node are stored in the table TYPES in a continuous manner. Beginning and end of the line area that represents the components are stored in TYPES-FROM and TYPES-TO. The reference to the superior node can be found in TYPES-BACK. If no superior resp. subordinate node exists, then this is marked by the value 0 (For the relevance of further components, refer to the following sections).
    The names of components, types etc. are not stored directly in TYPES. Instead, the components TYPES-IDX_... hold an index in the name table NAMES. The value 0 indicates that there is no reference to the name table.
    NAMES contains the possibly fragmented names in the component NAMES-NAME. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE.
    The type description table (TYPES) not only stores information about the tree structure but also further information about the type of f resp. its components. This includes especially all information that can be determined using the usual additions to DESCRIBE FIELD. In detail, TYPES contains the following columns:
    IDX_NAME
    Component Name
    IDX_USER_TYPE
    Name of a user-defined type, i.e., a type that was defined through its TYPES-statement. Derived types (... TYPE A-B) and structures from the ABAP-Dictionary are not considered to be user-defined types.
    CONTEXT
    For user-defined types only: The context, in which the type is defined. Possible values are defined in the constant SYDES_CONTEXT of the type group SYDES. Please only use these constants to carry out a comparison. In detail, we distinguish between the following type contexts:
    SYDES_CONTEXT-PROGRAM: Program-global type
    SYDES_CONTEXT-FORM   : FORM-local type
    SYDES_CONTEXT-FUNCTION: FUNCTION-local type
    SYDES_CONTEXT-METHOD : METHOD-local type
    IDX_CONTEXT_NAME
    For user-defined types only:
    With a local context: The name of the FORM or FUNCTION, whose type was defined. The name of the associated program is then the first entry in the name table.
    With a global context: The name of the program in which the type was defined.
    IDX_EDIT_MASK
    Conversion routine from the ABAP-Dictionary, is in accordance with the addition EDIT MASK at simple DESCRIBE.
    IDX_HELP_ID
    Help-Id when referencing to fields from the ABAP-Dictionary
    LENGTH
    Internal length, corresponds to the addition LENGTH at simple DESCRIBE
    OUTPUT_LENGTH
    Output length, corresponds to the addition OUTPUT-LENGTH at simple DESCRIBE
    DECIMALS
    Number of decimal digits, corresponds to the addition DECIMALS at simple DESCRIBE
    TYPE
    ABAP-Type, corresponds to the addition TYPE at simple DESCRIBE
    TABLE_KIND
    A table type is stored here for the components which represent an internal table. The same values are returned as with the variant DESCRIBE TABLE itab KIND k. Components which do not represent a table get the return value set to SYDES_KIND-UNDEFINED (see type group SYDES).
    Example
    Example definition of the complex data type EMPLOYEE_STRUC:
    PROGRAM DESCTEST.
    TYPES: BEGIN OF name_struc,
             first  TYPE c LENGTH 20,
             last   TYPE c LENGTH 20,
           END OF name_struc,
           BEGIN OF absence_time_struc,
             day        TYPE d,
             from       TYPE t,
             to         TYPE t,
           END OF absence_time_struc,
           phone_number TYPE n LENGTH 20,
           BEGIN OF employee_struc,
             id         LIKE sbook-customid,
             name       TYPE name_struc,
             BEGIN OF address,
               street  TYPE c LENGTH 30,
               zipcode TYPE n LENGTH 4,
               place   TYPE c LENGTH 30,
             END OF address,
             salary_per_month TYPE p LENGTH 10 DECIMALS 3,
             absent           TYPE STANDARD TABLE OF absence_time_struc
                                   WITH NON-UNIQUE DEFAULT KEY,
             phone            TYPE STANDARD TABLE OF phone_number
                                   WITH NON-UNIQUE DEFAULT KEY,
           END OF employee_struc.
    You can determine the structure of the type EMPLOYEE_STRUC by collecting the type group SYDES as follows:
    TYPE-POOLS: sydes.
    DATA: employee TYPE employee_struc,
          td       TYPE sydes_desc.
    DESCRIBE FIELD employee INTO td.
    The following table shows a few selected columns of the type description table TD-TYPES. For a better overview, the names of the columns IDX_NAME, IDX_UERR_TYPE and IDX_EDIT_MASK have been shortened:
        |FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
    |--||||||--
      1 |  2 |  7 |  0 |  0 |  2 |  0 |  v
      2 |  0 |  0 |  1 |  6 |  0 |  4 |  N
      3 |  8 |  9 |  1 |  7 |  5 |  0 |  u
      4 | 10 | 12 |  1 |  8 |  0 |  0 |  u
      5 |  0 |  0 |  1 |  9 |  0 |  0 |  P
      6 | 13 | 13 |  1 | 11 |  0 |  0 |  h
      7 | 17 | 17 |  1 | 12 |  0 |  0 |  h
      8 |  0 |  0 |  3 | 13 |  0 |  0 |  C
      9 |  0 |  0 |  3 | 14 |  0 |  0 |  C
    10 |  0 |  0 |  4 | 15 |  0 |  0 |  C
    11 |  0 |  0 |  4 | 16 |  0 |  0 |  N
    12 |  0 |  0 |  4 | 17 |  0 |  0 |  C
    13 | 14 | 16 |  6 |  0 | 18 |  0 |  u
    14 |  0 |  0 | 13 | 20 |  0 |  0 |  D
    15 |  0 |  0 | 13 | 21 |  0 |  0 |  T
    16 |  0 |  0 | 13 | 22 |  0 |  0 |  T
    17 |  0 |  0 |  7 |  0 |  0 |  0 |  N
    Please note that the entries in rows 6 and 7 represent internal tables (ABAP-Type h). There is always an entry for the corresponding row type (rows 13 and 17) to an internal table.
    The indices in the rows 5 to 7 refer to entries in the name table TD-NAMES. If you look, e.g., at row 3, you find the corresponding component name in TD-NAMES from row 7 (NAME) onward and the corresponding user type from row 5 (NAME_STRUC) onward.
    In the name table TD-NAMES you find the following entries. Note that the names SALARY_PER_MONTH and ABSENCE_TIME_STRUC are stored in two parts:
        |CONTINUE|NAME                   |CONTINUE|NAME
    |--|     -||--
      1 |        |DESCTEST            12 |        |PHONE
      2 |        |EMPLOYEE_STRUC      13 |        |FIRST
      3 |        |SBOOK-CUSTOMID      14 |        |LAST
      4 |        |==ALPHA             15 |        |STREET
      5 |        |NAME_STRUC          16 |        |ZIPCODE
      6 |        |ID                  17 |        |PLACE
      7 |        |NAME                18 |   *    |ABSENCE_TIME_ST
      8 |        |ADDRESS             19 |        |RUC
      9 |   *    |SALARY_PER_MONT     20 |        |DAY
    10 |        |H                   21 |        |FROM
    11 |        |ABSENT              22 |        |TO

  • How to fetch the latest change number from CDPOS Table..?

    Hi All,
    im trying to fetch teh change number from CDPOS with the below select, but my requirement is always i wants to fetch the latest change number.
              SELECT SINGLE objectid changenr FROM cdpos
                     INTO wa_cdpos
                     WHERE objectid = wa_e1kna1m-kunnr
                     AND ( tabname = 'KNA1' OR tabname = 'KNVV')
                     AND   fname = 'AUFSD'
                     AND ( value_new = '01' OR value_new = space ).
    Please let me know how to achive this..?
    Ashok

    try this way
    "           SELECT SINGLE objectid changenr FROM cdpos
    "                 INTO wa_cdpos
               SELECT objectid changenr FROM cdpos
                      INTO table t_cdpos
                      WHERE objectid = wa_e1kna1m-kunnr
                      AND ( tabname = 'KNA1' OR tabname = 'KNVV')
                      AND   fname = 'AUFSD'
                      AND ( value_new = '01' OR value_new = space ).
    SORT t_cdpos by  changenr Descending.
    read t_cdos index 1.    "this is the latest change
    Prabhudas

  • How to fetch the data from a pl/sql table and varray, with some example

    I want to fetch the data using a cursor from Pl/sql table and varry and I want to update the data.
    Please provide me some example.

    PL/SQL Table  - please note that, right term is Associative Array.
    Presumably you are referring to the 'often heated' back-and-forth that sometimes goes on in the forums when people refer to ANY PL/SQL type using a term with the word 'table' in it?
    Curious that you then show an example of a nested table!
    type emp_tab is table of employees%rowtype;
    The 'right term' for that is 'nested table'. The following would be an 'associative array' or 'index-by table'
    type emp_tab is table of employees%rowtype INDEX BY PLS_INTEGER;
    Those used to be called 'PL/SQL tables' or 'index-by tables' but 'associative array' is the current term used.
    Associative Arrays
    An associative array (formerly called PL/SQL table or index-by table) is a set of key-value pairs. Each key is a unique index, used to locate the associated value with the syntax variable_name(index).
    The data type of index can be either a string type or PLS_INTEGER.
    Since the Oracle docs often use 'PL/SQL table' or 'index-by table' it isn't unusual for someone asking a question to use those terms also. Technically the types may not be 'tables' but it's clear what they mean when they use the term.
    In PL/SQL the term 'nested table' is still used even though the PL/SQL collection is not really a table. SQL does have nested tables where the data is actually stored in a table. The PL/SQL  'nested table' type can be used as the source/destination of the SQL data from a nested table so that may be why Oracle uses that term for the PL/SQL type.
    The doc that SKP referenced refers to this use:
    Nested Tables
    In the database, a nested table is a column type that stores an unspecified number of rows in no particular order. When you retrieve a nested table value from the database into a PL/SQL nested table variable, PL/SQL gives the rows consecutive indexes, starting at 1.

  • How to delete the matching records from two internal tables

    Hi ,
    I have two internal tables say A and B of the same type. If A has 10 records and B has 4 records , I want to delete the 4 records in B from A .
    loop at B into wa .
    delete A where key = wa - key .
    endloop.
    takes a long time if the table B is huge. how can I improve the performance.
    Thanks.
    Gayathri

    Hi Gayathri,
    You could try field-symbols. It reduces the data transfer from the internal table B to the work area.
    field-symbols <fs_itab_b> like line of B.
    loop at B assigning <fs_itab_b>.
      delete A where key = <fs_itab_b>?-key.
    endloop.
    Regards,
    <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=zwcc%2fwm4ups%3d">anand Mandalika</a>.

  • How to count no of line present in internal table depending on condtion.

    Hi,
    I want to count no of line present in one internal table.
    For example: I have an internal table with output tax line item
    lwa_gt_alv-ty_auste_ep consider this internal table having 100 lines
    depending on the condition copany code(BUKRS), Year(GJAHR), and Document number(BELNR).
    I want to count the number of line present for above mentioned condition in internal table lwa_gt_alv-ty_auste_ep.
    Kindly help as soon as possible.
    Thanks and best regards,
    Niteesh Rai

    Hello
    So, count into exist loop/endloop:
    data: counter type i.
    loop at itab.
    * do anything here ...
      if BUKRS = " condition for bukrs here
      and GJAHR = " condition for gjahr here
      and BELNR = " condition for belnr here
        counter = counter + 1.
      endif.
    * do anything here ...
    endloop.
    write counter.
    Also you may to try other way:
    data: counter type i.
    data: itab1 like itab occurs 0.
    itab1[] = itab[].
    delete itab1 where BUKRS NE " condition for bukrs here
                   and GJAHR NE " condition for gjahr here
                   and BELNR NE " condition for belnr here
    describe table itab1 lines counter.
    write counter.

  • How to upload the flat file records into internal table by position?

    Hi
    I have a flat file which has 7 records in each row and they are NOT provided with CSV or Tab demilited...
    They are continous text without spaces....
    but i know the fixed length of each field Eg : 1st field 7 char and seconc field 3 char and so on...
    How can i upload this file into internal table by reading positions of each field...I know we can use GUI_UPLOAD and Read dataset and Open dataset...
    But please let me know to read the file with the fixed postions and load into internal table...
    Thanks in advance
    MM

    Hi
    As per my knowledge i dont think thr is some function module or so to read with a fixed positions.
    You can use the below method if you think this is the best way.
    Suppose your file has
    types : begin of ty_itab,
                field1 type char7,
                field2 type char3,
                field3 type chat3,
                field4 type char3,
                end of ty_itab.
    types : begin of ty_upload,
                 str type string,
                end of ty_upload.
    data : it_itab type standatd table of ty_itab,
              it_upload type standard table ot ty_upload,
              wa_itab type ty_itab,
              wa_upload type ty_upload.
    use gui_upload.get the data in it_upload.
    here you know that u have first 16 charcters makes a first row n then next 16 charcters next row
      Loop at it_upload into wa_upload.
       v_len =  strlen ( wa_upload ).
       v_len = v_len / 16.
        You get number of rows per record ,if it is decimal value make it final value if 3.9 make to 4.
        do v_len times.
          wa_itab = wa_upload.
          By this only first 16 characters are moved and respective fields will get a value.or else u can use offset
           wa_upload+0(16).
          append wa_itab to it_itab.
          Now shift 16 characters using shift command in wa_upload.
        enddo.
      endloop.
    Hope this syntax help you to resolve your issue.May be something i have missed .Right now i don't have sap system to send you the full correct syntax code.
    Cheers
    Joginder

  • Debugging ECC6: how to see the fields name when download internal table?

    When we debug a reprot in ECC6 and save to a local file an internal table, the fields are not appearing only the data,
    Is there a way to download also the table fields name?

    From the new debugger switch to the classic debugger using menu path Debugger->Switch to Classic Debugger. Form the classic debugger you can download internal table data with column name(s).
    Regards,
    Joy.

  • Inserting a line in a internal table

    Hello guys , I want to insert in the forst line of my internal table son titles in order to move the entire table to txt file , But I dont kno how I can put the titles in the first line, any suggestion ? DO I have to use a index?

    Where are you writing the text file??
    If you are using GUI_download, then you can pass the header text( in a different internal table) to the FM.
    If you are using open dataset you can write the header first and then the internal table.
    I dont think inserting text in the data table is a good idea.

  • How to delete the logical lines in JTextArea

    Hi all,
    Now that I know how to find the logical line count in JTextArea as
    I found the following in the forum.
    public static int getLineCount (JTextArea _textArea)
    boolean lineWrapHolder = _textArea.getLineWrap();
    _textArea.setLineWrap(false);
    double height = _textArea.getPreferredSize().getHeight();
    _textArea.setLineWrap(lineWrapHolder);
    double rowSize = height/_textArea.getLineCount();
    return (int) (_textArea.getPreferredSize().getHeight() / rowSize);
    I want to delete the 4th line to the last line and append ... at the 4th, if the getLineCount exceeds 3. Does any body know how to do so?
    The intention is for the multiline tooltip as I just want to show
    the first three logical line and ... if the string is too long.
    Thanks
    Pin

    The code looks good to me. The only thought I have is that the y coordinate for the rowThree point is wrong and is referencing row four.
    I've been playing around with using a JTextArea as a renderer for a JTable. I have it working so that "..." appear when the text exceeds 2 rows. Try clicking on "B" in the letter column and then the update cell button a few times to add text. My code is slightly different than yours.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TestTable extends JFrame
         private final static String LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
         JTable table;
         Vector row;
         public TestTable()
              Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"} };
              String[] columnNames = {"Number","Letter"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              table = new JTable(model)
                   public String getToolTipText( MouseEvent e )
                        int row = rowAtPoint( e.getPoint() );
                        int column = columnAtPoint( e.getPoint() );
                        if (row == 0)
                             return null;
                        else
                             return row + " : " + column;
              table.setRowSelectionInterval(0, 0);
              table.setColumnSelectionInterval(0, 0);
              table.setRowHeight(0,34);
              table.setRowHeight(1,34);
              table.setRowHeight(2,34);
              table.setDefaultRenderer(Object.class, new TextAreaRenderer(2));
              JScrollPane scrollPane = new JScrollPane( table );
              getContentPane().add( scrollPane );
              JPanel buttonPanel = new JPanel();
              getContentPane().add( buttonPanel, BorderLayout.SOUTH );
              JButton button2 = new JButton( "Update Cell" );
              buttonPanel.add( button2 );
              button2.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent e)
                        int row = table.getSelectedRow();
                        int column = table.getSelectedColumn();
                        String value = (String)table.getValueAt(row, column);
                        value += value;
                        table.setValueAt( value, row, column );
                        DefaultTableModel model = (DefaultTableModel)table.getModel();
                        model.fireTableCellUpdated(row, column);
                        table.requestFocus();
         public static void main(String[] args)
              TestTable frame = new TestTable();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setVisible(true);
         private class TextAreaRenderer extends JTextArea implements TableCellRenderer
              public TextAreaRenderer(int displayRows)
                   setRows(displayRows);
                   setLineWrap( true );
              public Component getTableCellRendererComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             boolean hasFocus,
                                             int row,
                                             int column)
                   setText( value.toString() );
                   Dimension d = getPreferredSize();
                   int maximumHeight = getRows() * getRowHeight();
                   if (d.height > maximumHeight)
                        setSize(d);
                        int offset = viewToModel( new Point(d.width, maximumHeight - 1) );
                        replaceRange( "...", offset-3, getDocument().getLength() );
                   return this;
    }

  • How to delete the specified line in file?

    How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
    Line 1
    Line 2
    Line 3
    Line 4
    Line 5
    The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?

    An alternative solution can be :
    import java.io.LineNumberReader;
    import java.io.IOException;
    import java.io.File;
    import java.io.FileReader;
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.PrintWriter;
    public class LineDeleter {
    public static void main(String args[]){
    try {
    //suppose you want to delete line 3
         int lineToBeDeleted = 3;
         File f = new File("line.txt");
         long fileSize = f.length();
    //Wrap the FileReader with a LineNumberReader. It will help you
    //identify the lines.
    LineNumberReader lnr = new LineNumberReader( new FileReader(f));
    //Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
    //equal to the file size.
         BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
    //Wrap BufferedWriter object with PrintWriter so that it allows you
    //to print line by line
    PrintWriter pw = new PrintWriter(bw);
         String s=null;
         while ( (s=lnr.readLine())!=null ){
              System.out.println(s);
              int lineNumber = lnr.getLineNumber();
    //match the line number
              if(! (lineNumber==lineToBeDeleted)){
                   pw.println(s);
              pw.flush();
              lnr.close();
              pw.close();
         catch(Exception e){System.out.println(e);}
    If you want you can rename the line1.txt to the original file name.
    I hope this helps.Good luck!!!!!!

Maybe you are looking for