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

  • Home
  • SEARCH
  • 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 1101495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:02:41+00:00 2026-05-17T01:02:41+00:00

I have a linux server and many clients with many operating systems. The server

  • 0

I have a linux server and many clients with many operating systems. The server takes an input file from clients. Linux has end of line char LF, while Mac has end of line char CR, and
Windows has end of line char CR+LF

The server needs as end of line char LF. Using java, I want to ensure that the file will always use the linux eol char LF. How can I achieve it?

  • 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-17T01:02:42+00:00Added an answer on May 17, 2026 at 1:02 am

    Combining the two answers (by Visage & eumiro):

    EDIT: After reading the comment. line.
    System.getProperty("line.separator") has no use then.
    Before sending the file to server, open it replace all the EOLs and writeback
    Make sure to use DataStreams to do so, and write in binary

    String fileString;
    //..
    //read from the file
    //..
    //for windows
    fileString = fileString.replaceAll("\\r\\n", "\n");
    fileString = fileString.replaceAll("\\r", "\n");
    //..
    //write to file in binary mode.. something like:
    DataOutputStream os = new DataOutputStream(new FileOutputStream("fname.txt"));
    os.write(fileString.getBytes());
    //..
    //send file
    //..
    

    The replaceAll method has two arguments, the first one is the string to replace and the second one is the replacement. But, the first one is treated as a regular expression, so, '\' is interpreted that way. So:

    "\\r\\n" is converted to "\r\n" by Regex
    "\r\n" is converted to CR+LF by Java
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linux server has an ad-hoc wireless network for clients to connect
I have a linux server, I am looking to convert a .wma file to
How to send messages from php to node.js? I have a linux server running
I have recently had a linux server compromised from bots uploading .php scripts and
(I have a Linux server and My computer's operating sysyem is Windows.) Hi. I've
Here's my question. Right now I have a Linux server application (written using C++
I have a server that is running Ubuntu Linux Server Edition. I once had
We have a remote repository on a linux server. When I work on a
I have setup a git repository in a linux server, and installed the latest
I have a website hosted on a Linux server. If someone sends me an

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.