Java XML String Transform replaceLineSeparatorInternal(String string, String lineSeparator)

Here you can find the source of replaceLineSeparatorInternal(String string, String lineSeparator)

Description

Do not use outside of CDT. This method is a workaround for javax.xml.transform.Transformer not being able to specify the line separator.

License

Open Source License

Parameter

Parameter Description
string - the string to be replaced
lineSeparator - line separator to be used in the string

Declaration

public static String replaceLineSeparatorInternal(String string,
        String lineSeparator) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009, 2013 Andrew Gvozdev (Quoin Inc.).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w  w  w.ja v a2  s  . c om
 *     Andrew Gvozdev (Quoin Inc.)
 *******************************************************************************/

public class Main {
    private static String LINE_SEPARATOR = System
            .getProperty("line.separator");

    /**
     * <b>Do not use outside of CDT.</b> This method is a workaround for {@link javax.xml.transform.Transformer}
     * not being able to specify the line separator. This method replaces a string generated by
     * {@link javax.xml.transform.Transformer} which contains the system line.separator with the line separators
     * from an existing file or the preferences if it's a new file.
     *
     * @param string - the string to be replaced
     * @param lineSeparator - line separator to be used in the string
     * 
     * @noreference This method is not intended to be referenced by clients.
     *    This is an internal method which ideally should be made private.
     */
    public static String replaceLineSeparatorInternal(String string,
            String lineSeparator) {
        string = string.replace(LINE_SEPARATOR, lineSeparator);
        return string;
    }
}

Related

  1. readFile(String fileName)
  2. readFile(String systemId)
  3. readURL(String urlStr)
  4. readXMLFile(String xmlFileName)
  5. render(String name, byte[] xmldata)
  6. save(Node doc, OutputStream stream, String encoding, boolean indent)
  7. signEmbeded(Node doc, String uri, PrivateKey pKey, X509Certificate cert)
  8. String2Doc(String InputXMLString)
  9. string2Source(String xml)