In Java, of course. I’m writing a program and running it under a Windows environment, but I need the output (.csv) to be done in Unix format. Any easy solution? Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Note: as reported in comments, the approach given below breaks in JDK 9+. Use the approach in James H.’s answer.
By “Unix format” do you mean using “\n” as the line terminator instead of “\r\n”? Just set the
line.separatorsystem property before you create the PrintWriter.Just as a demo:
Of course that sets it for the whole JVM, which isn’t ideal, but it may be all you happen to need.