My Deskjet 1056 cuts the last line off of the page

My Deskjet 1056 cuts half the last line of every page off. No matter what I'm printing from where. I've tried changing margins and printing areas and borders. I've heard to try changing the drivers to 990c or 450 . neither make a difference. Changing the port from bidirectional makes it worse. Even tried to change the print processor modes. No luck. Does anyone have any suggestions. When I print and alignment page the squares at the bottom print just fine and align the page just fine so that doesn't help either. I run on Windows7 I don't know if that has anything to do with it. PLEASE HELP. Thanks in advance

Hi ! Welcome to the HP Forums. I understand you are having an issue with printouts being cut off at the bottom when printing to your HP Deskjet 1056 All-in-One printer from your Windows 7 computer. I'd love to help you with this. The first thing I would suggest would be to make a copy on the printer itself. If the bottom of the page is cut off, then it could be an issue with the hardware. If the copy comes out fine, then we know the hardware is functioning properly. If the copy comes out fine, I would suggest installing the full feature software for you printer if you haven't already. You can download the software here: HP Deskjet Full Feature Software and Drivers If that doesn't resolve the issue please download and run the HP Print and Scan Doctor and let me know of any errors or messages you receive. Have you tried printing multiple documents? Or printing from alternate programs to see if it might be an issue with a specific document or program? I look forward to hearing back from you and working towards a resolution. Thanks for posting!

Similar Messages

  • Final total cannot appear when the last line item reached the page end

    Hi All,
    My report included 2 pages. Problem is the final total cannot appear when the last line item reached the page end. (page 2)
    final total will appear on the middle of last page (page 3) when i comment (type    = 'BOTTOM').
    Below is the program.
      CALL FUNCTION 'OPEN_FORM'
        EXPORTING
          device   = 'PRINTER'
          dialog   = 'X'
          form     = 'ZBOTM_VOUCHER'
          language = sy-langu.
      sort itab by vblnr.
      LOOP AT itab INTO wa_itab.
        move wa_itab-vblnr to reguh-vblnr.
        move wa_itab-lifnr to reguh-lifnr.
        move wa_itab-rbetr to reguh-rbetr.
        reguh-rbetr = reguh-rbetr * -1.
        CALL FUNCTION 'WRITE_FORM'
          EXPORTING
            window  = 'MAIN'
            element = 'DETAIL'.
        t_rbetr = reguh-rbetr + t_rbetr.
        AT LAST.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              window = 'LINE'.
          CALL FUNCTION 'WRITE_FORM'
            EXPORTING
              element = 'TOTAL'.
              type    = 'BOTTOM'
              WINDOW  = 'MAIN'.
        ENDAT.
    Thanks.

    Hi,
    Where should I include the code for bottom?
    How to open text editor?
    Thanks.
    Edited by: Alice8 on Feb 7, 2011 9:09 AM

  • How to only read the last line in the text file by using BufferedReader ?

    Dear all,
    Hello, I am new to Java. Do anybody know how to read the last line (this is the last record) in the text file.The method I am now using is reading from the first line until I reach the last line in the text file. Thank you!!
    BufferedReader br = new BufferedReader(new FileReader("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    DataInputStream in = new DataInputStream(new FileInputStream("c:\\sdk1.4.1\\bin\\dbExport.txt"));
    String input;
    String firstinput;
    String secondinput;
    int count=90;
    int year=1955;
    while ((input = br.readLine()) != null) {
    firstinput = input.substring(0, 10);
    secondinput = input.substring(10);
    String insertStore1 = ("INSERT INTO AUTHORS " +
    "VALUES ('" + count + "', '" + firstinput + "', '" + secondinput + "', 1955)");
    System.out.println(insertStore1);
    int result = stmt.executeUpdate(insertStore1);

    I suppose you could use a java.io.RandomAccessFile.

  • Can I align the last line of a text container to to bottom of a container?

    Is it possible to take the last line in a text container and vertically align it to the bottom? I'm aware that I can justify the entire text container vertically to achieve this effect. However, this means tha every line in the container is now spaced out with increased leading.
    Here's a screen capture of what I mean.
    On the right is a text container without any vertical justification and sized to fit the text. On the left is a text container that I've sized to match the height of the right container. In order to get the last line to align to the bottom I used the Justify vertically option. But my bullets are now spread out.
    Basically I just want the last line aligned to the bottom and the rest of the text above it to be aligned to the top.
    Is there anyway to do this with just one text container? Or will I be forced to used two text containers?
    I'm using InDesign CS5 if that matters.

    I think I'd do this with a two-cell table.

  • How can i remove gaps between letters, usually occur in a paragraph justified with the last line aligned right/left

    here's an example of a paragraph i've taken from wikipedia:
    if you can see, in the paragraph aligned with the button "Justify with the last line aligned left" - the one above, i've marked with red lines the places in which a gap occurs all of a sudden, and i cannot undo them.
    for the same paragraph below i used the simple "Align left" button.
    can anyone please help me understand what has happened that made those gaps occur.
    i use Adobe Design Standard CS 6 Middle East Version. this bug occurs in other font/languages as well.

    Thank you for providing the sample IDML file.
    I still think it could be the used paragraph composer, maybe in conjunction with the used font. I'd change the composer to see, if the problem will go away.
    @Willi – you are right, the story direction is RTL, but the paragraph direction is LTR. That's no surprise here since the ME version of InDesign was used.
    I would change story direction to LTR, use the "normal" paragraph composer instead the global one.
    Since the used font is not available to me, a substituted font is not showing the problem.
    But that may mean nothing. I do not use the ME version of InDesign…
    Uwe

  • I cant't read the last line in the grid

    hello,
    I use a grid to display a SQL query with a field-entry
    When I loop through the grid, I manage to read all lines except the line or the cursor, it keeps the old value
    Do you have an idea
    Thank you

    It's my code
            Shared Sub ItemEvent_Maj_emplacement_lot(ByRef FormUID, ByRef pVal, ByRef BubbleEvent)
                Dim EventEnum As SAPbouiCOM.BoEventTypes
                EventEnum = pVal.EventType
                If pVal.ItemUID = "1" Then
                    Dim jj As Integer
                    EventEnum = pVal.EventType
                    If EventEnum = BoEventTypes.et_CLICK Then
                        oform = SBO_application.Forms.Item(FormUID)
                       oitem = oform.Items.Item("MyGrid")
                        oGrid = oitem.Specific
                        Dim ColNum = oGrid.Columns.Count
                        Dim OgridCodeItem As Long
                        Dim OgridCodeMag As String
                        Dim OgridCodeLot As String
                        Dim OgridEmplacement As String
                        If oGrid.Columns.Count = 0 Then
                            Exit Sub
                        End If
                        For jj = 0 To oGrid.Columns.Count
                            Try
                                OgridCodeItem = oGrid.DataTable.GetValue(1, jj)
                                OgridCodeMag = oGrid.DataTable.GetValue(2, jj)
                                OgridCodeLot = oGrid.DataTable.GetValue(3, jj)
                                OgridEmplacement = oGrid.DataTable.GetValue(5, jj)
      ' This field OgridEmplacement is This field keeps the old value only on the last line before
    ' On the other lines, it works well
                            Catch oEx As Exception
                                '                          MessageBox.Show(oEx.Message & " jj = " & CStr(jj))
                                ' Exit Sub
                            End Try
                        Next jj
                    End If
                End If
            End Sub

  • How do I prevent Pages from pushing paragraphs to next page when they would otherwise begin on the last line of the previous page?

    I am writing papers for school which have strict page limits so I can't afford to be losing lines at the bottom of a page because Pages thinks it looks better to have a new paragraph start on the next page. It does this automatically and I have to go back and manually format to get the first line of the paragraph to start on the last line of the previous page. This then creates problems down the line when I am editing so I would really like to be able to turn the feature off.
    e.g. with Pages auto-formatting
    -----page 1-----
         Paragraph #1 blah blah
    blah blah blah
         Paragraph #2 blah blah
    blah blah blah
    -----page 2-----
         Paragraph #3 blah blah
    blah blah
    e.g. after manual formatting
    -----page 1-----
         Paragraph #1 blah blah
    blah blah blah
         Paragraph #2 blah blah
    blah blah blah
         Paragraph #3 blah blah
    -----page 2-----
    blah blah

    Change the keep with next rules in:
    Inspector > Text > More > Pagination & Break
    Peter

  • JSP for Vcard cannot strip carriage return in the last line of the file.

    I am using JSP to output a Vcard (http://en.wikipedia.org/wiki/VCard)
    The following code works great in Windows but fails on the mac:
    <%@ page contentType="text/x-vcard" %><%--
    --%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><%--
    --%><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %><%--
    --%>BEGIN:VCARD
    VERSION:2.1
    <c:choose><%--
    --%><c:when test="${not ((empty param.lan) and (empty param.fin)) }"><%--
    --%>N:${param.lan};${param.fin}
    FN:${param.fin} ${param.lan}
    </c:when><%--
    --%><c:otherwise><%--
    --%>FN:${param.org}
    </c:otherwise><%--
    --%></c:choose><%--
    --%>ORG:${param.org}
    TITLE:${param.title}
    TEL;WORK;VOICE:${param.phwork}
    ADR;WORK:;;${param.st};${param.city};${param.state};${param.zip};
    EMAIL;PREF;INTERNET:${param.email}
    REV:20080424T195243Z
    <c:out value="${fn:replace('END:VCARD','\\\r','')}" escapeXml="false"/>After some tests, I discovered that Mac (I used Tiger, latest update, not Leopard) needs extra white space and carriage returns stripped off. Once this is achieved, the vcard will automatically import into Address Book. I have followed other forums which advice on using JSP comments as in the code above. But for some strange reason the last line of the JSP outputs an extra carraige return. How do I get rid of the carriage return at the end of the file? the replace function from JSTL is not working.
    Edited by: shogo2040 on Dec 18, 2008 7:11 PM : I added more detail to the Subject

    I originally had that END:VCARD without any carriage return.
    But I still get an extra carriage return at the end when the JSP renders to VCF
    I'm using Tomcat running on Linux.
    I found this, article which implies (but does not explicitly say) JSP in general adds a newline to the last line:
    http://www.caucho.com/resin-3.0/jsp/faq.xtp (But its not tomcat either, so maybe this info is irrelevant).
    Edited by: shogo2040 on Dec 22, 2008 3:31 PM - changed rendered to VCF from rendered to JSP

  • Add a different character to the last line of a loop

    Hi,
    I'm attempting to use some pl/sql to generate an RMAN copy script. After each line there needs to be comma, but the last line of the loop should have a semi-colon to terminate the statement. How can I do that?
    In the example below, the copy for controlfile 3 needs to be a semi-colon, not a comma:
    run
    SHUTDOWN IMMEDIATE
    STARTUP MOUNT
    COPY
    DATAFILE 1 TO '/u20/oraflash/ORCL1/dbcopy/system01.dbf',
    DATAFILE 2 TO '/u20/oraflash/ORCL1/dbcopy/undotbs01.dbf',
    DATAFILE 3 TO '/u20/oraflash/ORCL1/dbcopy/drsys01.dbf',
    DATAFILE 4 TO '/u20/oraflash/ORCL1/dbcopy/example01.dbf',
    DATAFILE 5 TO '/u20/oraflash/ORCL1/dbcopy/indx01.dbf',
    DATAFILE 6 TO '/u20/oraflash/ORCL1/dbcopy/tools01.dbf',
    DATAFILE 7 TO '/u20/oraflash/ORCL1/dbcopy/users01.dbf',
    DATAFILE 8 TO '/u20/oraflash/ORCL1/dbcopy/xdb01.dbf',
    CURRENT CONTROLFILE TO '/u20/oraflash/ORCL1/dbcopy/control01.ctl',
    CURRENT CONTROLFILE TO '/u20/oraflash/ORCL1/dbcopy/control02.ctl',
    CURRENT CONTROLFILE TO '/u20/oraflash/ORCL1/dbcopy/control03.ctl',
    ALTER DATABASE OPEN
    My script is:
    set serveroutput on format wrapped
    set feedback off
    spool db_copy.rcv
    declare
    cursor df is
    select
    file#,
    substr(name,29,50) name
    from
    v$datafile;
    cursor cf is
    select
    substr(name,27,50) name
    from
    v$controlfile;
    BEGIN
    DBMS_OUTPUT.ENABLE(2000);
    DBMS_OUTPUT.PUT_LINE('run');
    DBMS_OUTPUT.PUT_LINE('{');
    DBMS_OUTPUT.PUT_LINE('SHUTDOWN IMMEDIATE');
    DBMS_OUTPUT.PUT_LINE('STARTUP MOUNT');
    DBMS_OUTPUT.PUT_LINE('COPY');
    for dfbkup in df loop
    dbms_output.put_line(' DATAFILE '||dfbkup.file#||
    ' TO ''' || '/u20/oraflash/ORCL1/dbcopy/' || dfbkup.name ||''',');
    end loop;
    for cfbkup in cf loop
    dbms_output.put_line(' CURRENT CONTROLFILE' ||
    ' TO ''' || '/u20/oraflash/ORCL1/dbcopy/' || cfbkup.name ||''',');
    end loop;
    DBMS_OUTPUT.PUT_LINE(' ;');
    DBMS_OUTPUT.PUT_LINE('ALTER DATABASE OPEN');
    DBMS_OUTPUT.PUT_LINE('}');
    end;
    spool off

    Hi
    Try this then and remove any returns that I've put in as appropriate
    DECLARE
    l_string VARCHAR2(32767);
    l_num NUMBER := 1;
    CURSOR df IS
    SELECT  file#, SUBSTR (name, 29, 50) name
    FROM v$datafile;
    CURSOR cf IS
    SELECT   SUBSTR (name, 27, 50) name
    FROM v$controlfile;
    BEGIN
       l_string := ('run
       l_string := l_string||('{
       l_string := l_string||('SHUTDOWN IMMEDIATE
       l_string := l_string||('STARTUP MOUNT
       l_string := l_string||('COPY
       FOR dfbkup IN df
       LOOP
          l_string := l_string||(   ' DATAFILE '
                               || dfbkup.file#
                               || ' TO '''
                               || '/u20/oraflash/ORCL1/dbcopy/'
                               || dfbkup.name
                               || ''',
       END LOOP;
       FOR cfbkup IN cf
       LOOP
          l_string := l_string||(   ' CURRENT CONTROLFILE'
                               || ' TO '''
                               || '/u20/oraflash/ORCL1/dbcopy/'
                               || cfbkup.name
                               || ''',
       END LOOP;
       l_string := RTRIM(l_string,'
       l_string := l_string||(' ;
       l_string := l_string||('ALTER DATABASE OPEN
       l_string := l_string||('}');
    WHILE l_num <= LENGTH(l_string) LOOP
    DBMS_OUTPUT.PUT_LINE(SUBSTR(l_string, l_num, 200));
    l_num := l_num + 200;
    END LOOP;
    END;Cheers
    Ben

  • Please add exit to the last line of the sql script

    Hi,
    I am executing a sql script from UNIX shell. When I execute it at the command prompt the script executes successfully, but when I schedule the script on cron, the script is throwing an error with the above message
    "Please add exit to the last line of the sql script"
    Any idea what is happening? Thanks in advance for any help
    thedba

    It works check this out..
    << script a.sh >>
    logfile=/home/oracle/sri/x.log
    sqlplus -s /nolog <<DOC >> ${logfile}
    whenever sqlerror exit sql.sqlcode
    connect scott/tiger
    @a.sql a.log
    DOC
    <<  script a.sql >>
    set feedback off
    set echo off
    spool &1
    select * from tab where tname like 'A%';
    spool off
    exit;
    << a.log >>
    TNAME                          TABTYPE  CLUSTERID                              
    AQ$DEF$_AQCALL                 VIEW                                            
    AQ$DEF$_AQERROR                VIEW                                            
    AQ$_DEF$_AQCALL_F              VIEW                                            
    AQ$_DEF$_AQERROR_F             VIEW                                            
    AQ$_INTERNET_AGENTS            TABLE                                           
    AQ$_INTERNET_AGENT_PRIVS       TABLE                                           
    AQ$_QUEUES                     TABLE                                           
    AQ$_QUEUE_TABLES               TABLE                                           
    AQ$_SCHEDULES                  TABLE                                           
    << x.log >>
    TNAME                          TABTYPE  CLUSTERID
    AQ$DEF$_AQCALL                 VIEW
    AQ$DEF$_AQERROR                VIEW
    AQ$_DEF$_AQCALL_F              VIEW
    AQ$_DEF$_AQERROR_F             VIEW
    AQ$_INTERNET_AGENTS            TABLE
    AQ$_INTERNET_AGENT_PRIVS       TABLE
    AQ$_QUEUES                     TABLE
    AQ$_QUEUE_TABLES               TABLE
    AQ$_SCHEDULES                  TABLE-Sri

  • How to find out the Last line of a page in Smart forms

    Hi Experts,
    I need to find out the <b>last line of a page in smartforms</b>.
    I have <b>Heading in a text element</b> and its <b>text in another text element</b>.
    If the heading falls in the last line, its contents will be displayed in the next page. I want to print the heading  in the next page.
    Please advise on this issue.
    Thanks in advance,
    Viven

    You can put both the heading and contents in a Folder node and check the page protection checkbox of the Folder node.  This way both will be displayed on the same page always.

  • How to upload CSV file w/o ,, for the last line

    Hi Experts,
    As part of one interface uploading the csv file (4coulmns) manually using the TCODE: CSCA_FILE_COPY.
    After uploading when i see in the AL11 as it is csv file it is filling the , in each space.
    But my issue while running the interface (because of logic in it) checking for the hash total in the last line where (record count, hash total) only 2 items should come but because of manual upload adding the (record count, hash total, , ,) another two spaces.
    Where program not moving further becasue the it is alway comparing the amounts (1000.00 not matching with 1000.00, , ) it is not processing. In production files directly load in to unix server so no issues and i can't ask to change the program code...because iam not following the process. As part of testing i've to do manually only.
    Please suggest the workaround for this.
    Is it possible to change the contents directly in AL11 directly....then HOW ?
    or
    How to create a csv file w/o , , in the last line (may be it is not possible) ?
    Thanks for your replies in advance.
    Regards
    VVR

    I don't think you can edit from AL11, nor creating a CSV without those commas at the end because are created to state fields with empty value.
    You have 6 columns filled with values but for the last line you only fill the first four. It is expected to appear , , for the last 2 columns on the last line.
    I can only suggest keep doing it manually before uploading the CSV file... or... you are saying you can't change the program.
    How about upload all CSV files... then writing another program to get those files from AL11 and delete the spare commas at the end line?
    Cheers,
    Andres.

  • Only the last line item is shown in main window...

    Hello Experts,
    I created a custom form for the standard checque program RFFOUS_C. Now, in my MAIN window, I
    called a subroutine in a custom program which loops through the line items but the problem is
    only the last line item is being shown. I tried using CONTROL_FORM to create a new line
    but it does not work. Note that I did not customize RFFOUS_C since it is being used by
    multiple companies. Below is my code:
    SAPSCRIPT:
    510-C
    Begin of insertion DEVK940799 11/10/2008 DEL_HIDALGO
    DEFINE &LTYC_XBLNR& = ''
    DEFINE &LTYC_BLDAT& = ''
    DEFINE &LTYC_SGTXT& = ''
    DEFINE &LTYC_DMBTR& = ''
    PERFORM WRITE_LINE_ITEMS IN PROGRAM Z9999RFI_Z2574FFI_RA
    USING &REGUH-LAUFD&
    USING &REGUH-LAUFI&
    USING &REGUH-XVORL&
    USING &REGUH-ZBUKR&
    USING &REGUH-LIFNR&
    USING &REGUH-VBLNR&
    CHANGING &LTYC_XBLNR&
    CHANGING &LTYC_BLDAT&
    CHANGING &LTYC_SGTXT&
    CHANGING &LTYC_DMBTR&
    ENDPERFORM
    PROTECT
         &LTYC_XBLNR&     &LTYC_BLDAT&     &LTYC_SGTXT&     &LTYC_DMBTR&
    ENDPROTECT
    End of insertion DEVK940799 11/10/2008 DEL_HIDALGO
    PROGRAM:
    IF gt_regup[] IS NOT INITIAL.
        CALL FUNCTION 'OPEN_FORM'
           EXPORTING
    *         APPLICATION                       = 'TX'
    *         ARCHIVE_INDEX                     =
    *         ARCHIVE_PARAMS                    =
    *         DEVICE                            = 'PRINTER'
    *         DIALOG                            = 'X'
             form                              = lcc_z2574ffi_ra
    *         LANGUAGE                          = SY-LANGU
    *         OPTIONS                           =
    *         MAIL_SENDER                       =
    *         MAIL_RECIPIENT                    =
    *         MAIL_APPL_OBJECT                  =
    *         RAW_DATA_INTERFACE                = '*'
    *         SPONUMIV                          =
    *       IMPORTING
    *         LANGUAGE                          =
    *         NEW_ARCHIVE_PARAMS                =
    *         RESULT                            =
           EXCEPTIONS
             canceled                          = 1
             device                            = 2
             form                              = 3
             OPTIONS                           = 4
             unclosed                          = 5
             mail_options                      = 6
             archive_error                     = 7
             invalid_fax_number                = 8
             more_params_needed_in_batch       = 9
             spool_error                       = 10
             codepage                          = 11
             OTHERS                            = 12.
        IF sy-subrc <> 0.
    *        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    *                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
        LOOP AT gt_regup INTO lw_regup.
          m_line_items 'LTYC_XBLNR' lw_regup-xblnr.
          m_line_items 'LTYC_BLDAT' lw_regup-bldat.
          m_line_items 'LTYC_SGTXT' lw_regup-sgtxt.
          m_line_items 'LTYC_DMBTR' lw_regup-dmbtr.
          DELETE ex_output WHERE value IS INITIAL.
          CALL FUNCTION 'WRITE_FORM'
           EXPORTING
             element                        = '510-C'
             function                       = 'APPEND'
    *         TYPE                           = 'BODY'
             window                         = 'MAIN'
    *       IMPORTING
    *         PENDING_LINES                  =
           EXCEPTIONS
             element                        = 1
             function                       = 2
             type                           = 3
             unopened                       = 4
             unstarted                      = 5
             window                         = 6
             bad_pageformat_for_print       = 7
             spool_error                    = 8
             codepage                       = 9
             OTHERS                         = 10.
          IF sy-subrc <> 0.
    *        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    *                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
          CALL FUNCTION 'CONTROL_FORM'
            EXPORTING
              command   = 'NEW-LINE'
            EXCEPTIONS
              unopened  = 1
              unstarted = 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.
        ENDLOOP.
        CALL FUNCTION 'CLOSE_FORM'
    *       IMPORTING
    *         RESULT                         =
    *         RDI_RESULT                     =
    *       TABLES
    *         OTFDATA                        =
           EXCEPTIONS
             unopened                       = 1
             bad_pageformat_for_print       = 2
             send_error                     = 3
             spool_error                    = 4
             codepage                       = 5
             OTHERS                         = 6.
        IF sy-subrc <> 0.
    *        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    *                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
      ENDIF.

    Hi,
    Write the at last event in the program and check if it works
      At last.
           CALL FUNCTION 'CONTROL_FORM'
            EXPORTING
              command   = 'NEW-LINE'
            EXCEPTIONS
              unopened  = 1
              unstarted = 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.
    Regards,
    Sravanthi

  • How to read the last line in a text file using text_io?? please help

    Dear all
    I made a procedure that append text into a text file on the operating system.
    the text file grows rapidly. It contains now about 200,000 line . I need to read the last line only . In other wprds i need to go direct to the last line to read some values. Is it possible??
    Please help

    Hello,
    If you know the number of the line you want to read, I can sugget you to use the MORE dos command or the TAIL unix command that redirect to a temporary text file
    Example to create a file that contains the 200010th last lines :
    (Client)Host( 'MORE the_file_name.txt +200010 > small_file.txt') ;So you have only to read the small file with the TEXT_IO functions.
    Francois

  • How to read the last line in a txt file?

    Dear all,
    I want to read the last line in a txt file. There are thousands of lines in this file. What I want is to move the file pointer directly to the last line of the file. But I did not know how do to it. Can anybody help me out?
    Thank you very much!

    If the file is coded as ASCII or one of the encodings that maps a single byte to a char then the following class will assist you
    import java.io.*;
    import java.util.*;
    public class GetLinesFromEndOfFile
        static public class BackwardsFileInputStream extends InputStream
            public BackwardsFileInputStream(File file) throws IOException
                assert (file != null) && file.exists() && file.isFile() && file.canRead();
                raf = new RandomAccessFile(file, "r");
                currentPositionInFile = raf.length();
                currentPositionInBuffer = 0;
            public int read() throws IOException
                if (currentPositionInFile <= 0)
                    return -1;
                if (--currentPositionInBuffer < 0)
                    currentPositionInBuffer = buffer.length;
                    long startOfBlock = currentPositionInFile - buffer.length;
                    if (startOfBlock < 0)
                        currentPositionInBuffer = buffer.length + (int)startOfBlock;
                        startOfBlock = 0;
                    raf.seek(startOfBlock);
                    raf.readFully(buffer, 0, currentPositionInBuffer);
                    return read();
                currentPositionInFile--;
                return buffer[currentPositionInBuffer];
            public void close() throws IOException
                raf.close();
            private final byte[] buffer = new byte[4096];
            private final RandomAccessFile raf;
            private long currentPositionInFile;
            private int currentPositionInBuffer;
        public static List<String> head(File file, int numberOfLinesToRead) throws IOException
            return head(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> head(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert encoding != null;
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new FileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                lines.addLast(line);
            reader.close();
            return lines;
        public static List<String> tail(File file, int numberOfLinesToRead) throws IOException
            return tail(file, "ISO-8859-1" , numberOfLinesToRead);
        public static List<String> tail(File file, String encoding, int numberOfLinesToRead) throws IOException
            assert (file != null) && file.exists() && file.isFile() && file.canRead();
            assert numberOfLinesToRead > 0;
            assert (encoding != null) && encoding.matches("(?i)(iso-8859|ascii|us-ascii).*");
            LinkedList<String> lines = new LinkedList<String>();
            BufferedReader reader= new BufferedReader(new InputStreamReader(new BackwardsFileInputStream(file), encoding));
            for (String line = null; (numberOfLinesToRead-- > 0) && (line = reader.readLine()) != null;)
                // Reverse the order of the characters in the string
                char[] chars = line.toCharArray();
                for (int j = 0, k = chars.length - 1; j < k ; j++, k--)
                    char temp = chars[j];
                    chars[j] = chars[k];
                    chars[k]= temp;
                lines.addFirst(new String(chars));
            reader.close();
            return lines;
        public static void main(String[] args)
            try
                File file = new File("/usr/share/dict/words");
                int n = 10;
                    System.out.println("Head of " + file);
                    int index = 0;
                    for (String line : head(file, n))
                        System.out.println(++index + "\t[" + line + "]");
                    System.out.println("Tail of " + file);
                    int index = 0;
                    for (String line : tail(file, "us-ascii", n))
                        System.out.println(++index + "\t[" + line + "]");
            catch (Exception e)
                e.printStackTrace();
    }Note, the EOL characters are treated as line separators so you will probably need to read the last two lines (think about it for a bit).

Maybe you are looking for