Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Fix Line Separator

import java.io.UnsupportedEncodingException; public class Utils {   public static String fixLineSeparator(String xml) throws UnsupportedEncodingException {     if ("\r\n".equals(System.getProperty("line.separator"))) {       xml = xml.replaceAll("\r[^\n]", System.getProperty("line.separator"));     } else {       xml = xml.replaceAll("\r\n", System.getProperty("line.separator"));     }     return xml;   } }