Java tutorial
//package com.java2s; import javax.annotation.Nonnull; public class Main { private static String newline = System.getProperty("line.separator"); @Nonnull public static String normalizeNewlines(@Nonnull String source) { return normalizeNewlines(source, newline); } @Nonnull public static String normalizeNewlines(@Nonnull String source, String newlineValue) { return source.replace("\r", "").replace("\n", newlineValue); } }