Adding a pipe character '|' at the end of each line

How can I add a '|' at the end of each line in a text file?
Please provide an example.
TIA

Using Readers and Writers are often a better choice for text: they are designed for character-based I/O, handling different character set encodings and thus more easily localizable.
BufferedReader and PrintWriter are buffered which in many cases will increase performance.
These classes also provide line-oriented methods, readLine() and println(), which will handle end-of-line delimiters in a platform-independant way.
BufferedReader in = null ;
PrintWriter out = null ;
try {
    in = new BufferedReader(new FileReader("infile.txt")) ;
    out = new PrintWriter(new FileWriter("outfile.txt")) ;
    String line ;
    while ((line = in.readLine()) != null) {
        out.print(line) ;
        out.println('|') ;
    out.flush() ;
} catch (FileNotFoundException e) {
    System.err.println("problem opening file for read: "+e) ;
} catch (IOException e) {
    System.err.println("problem reading file: "+e) ;
} finally {
    try {
        if (out != null) out.close() ;
        if (in  != null) in.close() ;
    } catch (IOException e) {
        System.err.println("problem closing files: "+e) ;
}

Similar Messages

  • How to delete a character at the end of each line in a file

    Hi
    How to remove a character or symbol at the end of each line in a file?
    I am having a file with every end of line conatins special chars @.
    I need to remove or delete that sysmbol from file.
    Regards

    JoeBorland wrote:
    File is large about above 20,000 lines.
    I need to find the optimum solution.
    Like reading a file and find the end of character and writing into a file.
    The above way is correct or any other way?Try it and see. Such a program will only be a dozen lines long.

  • Is it possible to export to PDF without a Return character at the end of every line?

    I am the author of a book whose first edition has been typeset and extensively amended in InDesign.  I now need to rewrite the first edition to produce a second edition.
    When I copy-and-paste from the PDF with which the publisher has supplied me into MS Word, I get a Return character at the end of every line, which means that text doesn’t automatically wrap and sentences are fragmented so that I get spurious grammar errors.
    I know that not all PDF files have a Return at the end of every line.  Is it possible to restrict Returns to the end of paragraphs when exporting from InDesign to PDF?  If so, what should the publisher be asking the typesetter to do?

    Thanks for your lightning-swift and helpful replies, Mike & Ellis.
    I don't have InDesign myself, so I know hardly anything about how it's used.  I'm just trying to research what an internationally-known publisher should already know how to do, but apparently doesn't!
    Following your suggestion, Mike, I have downloaded the trial version of Acrobat and exported the PDF to a Word file.  This has been moderately successful as there are far fewer spurious Return characters, just a few that I suspect may be hangovers from the typesetter having introduced soft returns in ID.
    As you've suggested Peter and Ellis, I'll suggest that the publisher asks the typesettter to export from ID to RTF and Text to see if that's even better.
    Message was edited 15:24 GMT by: AlanS5100

  • How to remove # from the end of each lines of .csv file.

    Hi ,
    I have uploaded .csv file from my local m/c (windows) to application server (unix) thru. FM 'ARCHIVFILE_CLIENT_TO_SERVER'
    Issue is when I open the file in AL11 it is showing # at end of each line. Click below link to see the output file.
    [https://docs0.google.com/document/edit?id=1PzjhljdCC2Wgj9L1dZ51G4pHJ0G_7jJwQAMqcJHdggc&hl=en#]
    Pls. help me how to remove all the # from the file.
    Thanks in advance.
    Devinder

    Hi ,
    use this
    Declare this 
    that # value is actually use of   Tab in file 
    so in order to remove that  use below code 
    DATA :C_TAB(1) TYPE c VALUE   cl_abap_char_utilities=>HORIZONTAL_TAB .
    loop at it_data .
    refno = it_data-line .
    REPLACE ALL OCCURRENCES OF c_tab IN refno WITH ''.
    modify it_data .
    endloop.
    Regards
    Deepak.

  • How can I eliminate automatic "quotation marks" that are appearing at the end of each line?

    I keep getting "quotation marks" at the end of every line when I type. How can I eliminate these marks as they are even showing up when I print and I will not have on my wedding programs! Please help (from a desperate bride-to-be)!

    It sounds like you are using an East Asian font and unless you are issuing invitations in Chinese, Japanese, or Korean that doesn't sound like a good idea.
    Peter

  • Getting weird symbols end the end of each line in Action script panel . Please help!!!!

    Let me know if anybody have got any clue to resolve this issue

    In the far upper right of the Actions panel is a small menu icon.  That includes the option for the menu-based route to turning the hidden characters on and off in case it ever happens again and you can't find this posting to help recall it.

  • BOX character at the end of line when file transferred from SAP to  WINDOWS

    Hi,
    We have a file interface program which creates a comma seperated '.txt' file in application server. Once it is created in application server in provided path an UNIX script runs which transfers this file from SAP application server to a network drive in WINDOWS platform. This file looks fine  when opened through WINSCP from SAP application server but when checked the file in network drive opened with note pad, it found each line come at the end of another line seperated by 'BOX' character.
    If we opened the file in word pad instead of note pad it looks fine.
    If any one of you have any idea to resolve this issue it will be a great help.
    Thanks,
    Ranadev

    Hi Ranadev,
    This happens because when you transfer the file to the Windows platform using the UNIX script it removes uses only a newline character at the end of each line instead of the Windows platform standard which is carriage return/newline.  The Notepad program displays this character alone as the box that you see.  If you want to verify take the same program and convert to Windows format using Notepad++ and you'll see that the same file then displays properly in Notepad.
    Regards,
    Ryan Crosby

  • Character # at the end of file in transaction AL11

    Hi gurus,
    In version 46c if I upload a file to application server with program RC1TCG3Z and in mode BIN when I display the file with transaction AL11 the file is correct.
    In version 60 if I upload a file to application server with the same program and in mode BIN when I display the file with transaction AL11 appears character # at the end of some lines. How it is possible?
    Thanks,

    Hi,
    U need to use one class. Refer below given code.
    TYPES : BEGIN OF lt_record_input,
              rec(1000) TYPE c,
            END OF lt_record_input.
    DATA : li_record_input TYPE TABLE OF lt_record_input .
    DATA lv_cr TYPE c.
    lv_cr = cl_abap_char_utilities=>cr_lf.
    CONCATENATE '/opt/isv/cti_app/DOCU/INCOMING/PROCESSED/UNSUCCESSFUL/'
    gv_filename INTO lv_path.
    OPEN DATASET lv_path FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc = 0.
      DO.
        READ DATASET lv_path INTO lw_record_input-rec.
        IF sy-subrc EQ 0.
          REPLACE lv_cr IN lw_record_input-rec WITH space.
          APPEND lw_record_input TO li_record_input.
        ELSE.
          EXIT.
        ENDIF.
      ENDDO.
      CLOSE DATASET lv_path.
    ENDIF.
    Hope it help u.

  • Character # at the end of line with transaction AL11

    Hi gurus,
    In version 46c if I upload a file to application server with program RC1TCG3Z and in mode BIN when I display the file with transaction AL11 the file is correct.
    In version 60 if I upload a file to application server with the same program and in mode BIN when I display the file with transaction AL11 appears character # at the end of some lines. How it is possible?
    Thanks,

    > I don't have access to OS level.
    Check the file on OS level (ask the admin to copy that file), it may be a display issue in the GUI.
    Markus

  • Finding the end of a line in a JTextArea and inserting a comma

    Hi,
    At the moment I am reading in a comma delimited file into a JTextArea.
    This part is ok I can see the file in the window correctly.
    The problem that I am having now is that I want to add a comma to the end of each line in the JTextArea.
    Does anyone know how to do this?
    Thank you

    Well you have to get the String value of the JTextField.
    String text = YourJTextField.getText()
    Then you have to make a loop and check each single character if it equals '\n', that means "RETURN" or "NEW LINE".
    That is the direction I would go. Inform yourself about String manipulations first, like how to look for character, how to compare them and how to add them.

  • Reg. Special Character at end of each line

    Hello Experts,
    I have an internal table of type string which has to be uploaded into the directories
    Each line has to be ended with a comma and for which I concatenated the work area and ',' before appending to the internal table.  This is fine till this point.
    After downloading the file from the directory, when opened with a notepad, i could see a special character (LINE FEED rectangular box) at the end of each line. 
    I couldn't understand why this character got appended at the end of each record.  Pl suggest me on how i can overcome this special character.
    Thanks
    RK

    Hi,
    I am developing one HRMS report for sending salaries to bank. Bank has given one format, there should be 24 spaces at the end of each line in the report. But I am not getting any spaces in the report at the end of line. I have tried soo many ways to get that, but I unable to get spaces. If I put any character it is coming, but if I put space that is not coming. For the line that is set the height of the Repeating Frame long enough to have the blank space. Vertical Elasticity should be expand.
    Also you can try by setting the property *"Vert. Space between frames"* for the Repeating frame.
    Hope this helps.
    Best Regards
    Arif Khadas

  • Space at end of each line in the RDF report.

    Hi All,
    I am developing one HRMS report for sending salaries to bank. Bank has given one format, there should be 24 spaces at the end of each line in the report. But I am not getting any spaces in the report at the end of line. I have tried soo many ways to get that, but I unable to get spaces. If I put any character it is coming, but if I put space that is not coming.
    Anyone please tell me how to get spaces at end of each line in RDF report. Its urgent guys...... Anyone please help me out.
    Thank you,
    Phani

    Hi,
    I am developing one HRMS report for sending salaries to bank. Bank has given one format, there should be 24 spaces at the end of each line in the report. But I am not getting any spaces in the report at the end of line. I have tried soo many ways to get that, but I unable to get spaces. If I put any character it is coming, but if I put space that is not coming. For the line that is set the height of the Repeating Frame long enough to have the blank space. Vertical Elasticity should be expand.
    Also you can try by setting the property *"Vert. Space between frames"* for the Repeating frame.
    Hope this helps.
    Best Regards
    Arif Khadas

  • How can I add a response to the end of each item question in an email list of questions and send that back to the originator?

    I have emails that ask for certian items to be addressed such as "please fix leak in bath sink" and then the next line will have another request and on and on. I would like to answer each question at the end of each line with a response (preferably in a different color font to stand out) such as "yes - will fix" or "that can't be done" or "you will have to fix that yourself". Then I want to send that reply back to the original sender.

    ''sfhowes [[#answer-697423|said]]''
    <blockquote>
    I suggest you consider this add-on: [https://addons.mozilla.org/en-US/thunderbird/addon/clippings/ Clippings] ([http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html How to install]).
    </blockquote>
    I did look int this but I need to have each answer different in a lot of cases but i thank you and did get an answer that does help greatly - Thanks

  • Inserting a '|' at the end of a line

    Is there a Windows script out there where you can add a '|' at the end of each line in a text file? Can you please provide an example?
    TIA

    Which version of photoshop cs6 are you using and operating system?
    Did you try resetting the type tool or resetting the photoshop cs6 preferences?
    Right click on the Big T on the tool options bar and click Reset Tool
    reset preferences:
    http://forums.adobe.com/thread/375776?tstart=0

  • ? at the beggining of  each line of TOC when I save to pdf?

    When I save a Framemaker 11 file to pdf I get a question mark inside of the > character at the beginning of each line of the generated table of contents in the pdf file. I have done everything that I can think of and can't get rid of it.

    The right angle bracket is FrameMaker's way of representing the
    invisible tab character. That's why it only shows in FM, not the PDF.
    You can use Alt v s to toggle display of invisible characters. It's
    usually best to leave them turned on.
    The question mark is FrameMaker's way of displaying a character that
    does not exist in your current font. For example, you might choose a
    character to use as a bullet for each item in a list. If you later
    change the paragraph to use a font that does not have that character
    defined, FrameMaker can no longer display it and shows you a question
    mark instead.
    So I think you need to look for that character in your file and replace
    it with something that will display. If it displays in FM, it should
    display in the PDF. Right now, it's displaying in neither. There are two
    places I can think of to look for it:
    1. Choose the affected paragraph format-- for example, Heading 1-- and
    look in its autonumbering properties. Someone may have assigned a
    character there. If this was meant to be a bullet, insert the bullet
    building block in place of whatever is there now.
    2. The other place to look is on the file's reference page (Esc v R).
    This is where you set up how FM content displays in generated files.
    Here, the paragraph format might be called Heading1TOC, for example.

Maybe you are looking for