Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 912985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:28:39+00:00 2026-05-15T17:28:39+00:00

I have a created text file in unix enviroment using java code. For writing

  • 0

I have a created text file in unix enviroment using java code.

For writing the text file i am using java.io.FileWriter and BufferedWriter.
and for newline after each row i am using bw.write(“\r\n”) method.
(where bw is object of BufferedWriter) and sending that text file by attaching in mail from unix environment itself to other environments like(mainframe,windows)

My issue is, if my client’s download the text file in Mainframe system,
they found that in text file a “special character”(like small rectangular box)
presenting and data not properly aligned.

bw.write(“\r\n”) is not working i think so..(but working fine in windows).

I want same text file alignment as it is in unix environment and without any special
character symbol too, if they opened the text file in mainframe ,windows environments
or any other enviroments.

How to resolve the problem. Thanks for your help in advance.

pasting my piece of java code here for your reference..(running java code in unix
environment)

File f = new File(strFileGenLoc);
BufferedWriter bw = new BufferedWriter(new FileWriter(f, false));
rs = stmt.executeQuery("select * from jpdata");
while ( rs.next() ) {
   bw.write(rs.getString(1)==null? "":rs.getString(1));
   bw.newLine();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:28:40+00:00Added an answer on May 15, 2026 at 5:28 pm

    Contrary to your claim, your code clearly isn’t writing “\r\n” after each line. It’s calling BufferedWriter.newLine() which uses the current platform’s default line separator (unless you explicitly set the line.separator system property). On Unix systems this will be “\n”.

    Now, you need to think about what you want the result to be on the target systems where it will be read. For Windows, that means you should explicitly write “\r\n”… I don’t know about the mainframes you mention though – you’d need to give more details.

    Note that the fact that there are different line separators available means that no one text file will be universally suitable. Many text editors on different platforms cope with any line separator… but there will always be some that don’t 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 474k
  • Answers 474k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Do you have control over the XML? If so, ensure… May 16, 2026 at 4:08 am
  • Editorial Team
    Editorial Team added an answer If you're are talking about database users... No, that is… May 16, 2026 at 4:08 am
  • Editorial Team
    Editorial Team added an answer var singleString = string.Join(",", _values.ToArray() ); May 16, 2026 at 4:08 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.