本文整理匯總了Java中org.jdom.output.Format.setLineSeparator方法的典型用法代碼示例。如果您正苦於以下問題:Java Format.setLineSeparator方法的具體用法?Java Format.setLineSeparator怎麽用?Java Format.setLineSeparator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jdom.output.Format
的用法示例。
在下文中一共展示了Format.setLineSeparator方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: toString
import org.jdom.output.Format; //導入方法依賴的package包/類
public String toString(Format format) {
StringWriter xmlout = new StringWriter();
try {
format.setLineSeparator(System.getProperty("line.separator"));
XMLOutputter outputter = new XMLOutputter(format);
outputter.output(this.element, xmlout);
// Close the FileWriter
xmlout.close();
} catch (java.io.IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return xmlout.toString();
}
示例2: toString
import org.jdom.output.Format; //導入方法依賴的package包/類
/**
* Return a pretty printed string formatted according to the JDOM Format
* @param format the Format object that controls the pretty printing.
* @return the pretty printed string.
*/
public String toString(Format format) {
StringWriter xmlout = new StringWriter();
try {
format.setLineSeparator(System.getProperty("line.separator"));
XMLOutputter outputter = new XMLOutputter(format);
outputter.output(this, xmlout);
// Close the FileWriter
xmlout.close();
} catch (java.io.IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return xmlout.toString();
}
示例3: flush
import org.jdom.output.Format; //導入方法依賴的package包/類
public void flush() throws IOException
{
XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
Format f = xmlcode.getFormat();
f.setEncoding("ISO-8859-1");
f.setTextMode(Format.TextMode.PRESERVE);
f.setLineSeparator(System.getProperty("line.separator"));
xmlcode.setFormat(f);
//Open a filewriter
PrintWriter writer = new PrintWriter(out);
xmlcode.output(doc, writer);
out.flush();
}
示例4: createXML
import org.jdom.output.Format; //導入方法依賴的package包/類
/**
* Write an XML file containing the interpretation of an expression
* @param e : expression which interpretation is to be saved
* @param file : path to the file to be created
*/
public static void createXML(Expression e, String file)
{
// Create the main node (root) of the XML
Element el = new Element("expression");
el.setAttribute(new Attribute("width", e.getDimension().width+"")); // Save the width ...
el.setAttribute(new Attribute("height", e.getDimension().height+"")); // ... and the height.
el.addContent(createSymbolNode(e.findLeftMost())); // Add the expression interpretation
// Create the document
Document doc = new Document(el);
try {
// Write the file
XMLOutputter outputter = new XMLOutputter();
Format f = outputter.getFormat(); // Set the format
f.setIndent(" "); // - indent
f.setLineSeparator("\r\n"); // - new lines
outputter.setFormat(f);
outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
} catch (IOException e1) {
e1.printStackTrace();
}
}
示例5: listOfSymbolXML
import org.jdom.output.Format; //導入方法依賴的package包/類
/**
* Write an XML file containing a list of symbols
* @param vc : list of symbols
* @param file : path to the file
*/
public static void listOfSymbolXML(Vector<Context> vc, String file)
{
// XML node with the list of symbols
Element e = listOfSymbols(vc);
// Creation of the XML document
Document doc = new Document(e);
// Write the file
try {
XMLOutputter outputter = new XMLOutputter();
Format f = outputter.getFormat();
f.setIndent(" ");
f.setLineSeparator("\r\n");
outputter.setFormat(f);
outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
} catch (IOException e1) {
e1.printStackTrace();
}
}
示例6: listsOfSymbolXML
import org.jdom.output.Format; //導入方法依賴的package包/類
/**
* Create an XML file containing the list of symbols for several expressions.
* @param ve : list of expressions
* @param file : file to save
*/
public static void listsOfSymbolXML(Vector<Expression> ve, String file) {
Element root = new Element("expressions");
for (Expression e: ve)
root.addContent(listOfSymbols(e.getSymbols()));
Document doc = new Document(root);
try {
XMLOutputter outputter = new XMLOutputter();
Format f = outputter.getFormat();
f.setIndent(" "); // use two space indent
f.setLineSeparator("\r\n");
outputter.setFormat(f);
outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
} catch (IOException e1) {
e1.printStackTrace();
}
}
示例7: JPFClasspathFixProcessor
import org.jdom.output.Format; //導入方法依賴的package包/類
public JPFClasspathFixProcessor()
{
super();
sax = new SAXBuilder();
sax.setValidation(false);
sax.setReuseParser(true);
sax.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Format format = Format.getRawFormat();
format.setOmitEncoding(true);
format.setOmitDeclaration(true);
format.setLineSeparator("\n");
format.setEncoding("UTF-8");
xmlOut = new XMLOutputter(format);
}
示例8: NewPluginWizard
import org.jdom.output.Format; //導入方法依賴的package包/類
public NewPluginWizard()
{
fFirstPage = new NewJPFPluginWizardPageOne();
fSecondPage = new NewJavaProjectWizardPageTwo(fFirstPage);
Format format = Format.getPrettyFormat();
format.setIndent("\t");
format.setOmitEncoding(true);
format.setOmitDeclaration(true);
format.setLineSeparator("\n");
format.setEncoding("UTF-8");
xmlOut = new XMLOutputter(format);
}
示例9: toString
import org.jdom.output.Format; //導入方法依賴的package包/類
public String toString(Format format) {
StringWriter xmlout = new StringWriter();
try {
format.setLineSeparator(System.getProperty("line.separator"));
XMLOutputter outputter = new XMLOutputter(format);
outputter.output(this, xmlout);
// Close the FileWriter
xmlout.close();
} catch (java.io.IOException e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
return xmlout.toString();
}
示例10: assertXmlOutputEquals
import org.jdom.output.Format; //導入方法依賴的package包/類
private static void assertXmlOutputEquals(String expected, Element root) throws IOException {
StringWriter writer = new StringWriter();
Format format = Format.getPrettyFormat();
format.setLineSeparator("\n");
new XMLOutputter(format).output(root, writer);
String actual = writer.toString();
assertEquals(expected, actual);
}
示例11: createPrettyFormat
import org.jdom.output.Format; //導入方法依賴的package包/類
private Format createPrettyFormat() {
final Format prettyFormat = Format.getPrettyFormat();
prettyFormat.setExpandEmptyElements(expandEmptyElements);
prettyFormat.setEncoding(encoding);
prettyFormat.setLineSeparator("\n");
prettyFormat.setIndent(indentCharacters);
return prettyFormat;
}
示例12: getFormat
import org.jdom.output.Format; //導入方法依賴的package包/類
public static Format getFormat(String indent, boolean newlines) {
Format format = Format.getPrettyFormat();
format.setIndent(indent);
if (newlines) {
format.setLineSeparator("\n"); //$NON-NLS-1$
} else {
format.setLineSeparator(""); //$NON-NLS-1$
}
return format;
}
示例13: writeXML
import org.jdom.output.Format; //導入方法依賴的package包/類
/**
* Serializes the database to the output stream.
*
* @param outputStream the output
* @param encoding the encoding to use
* @param indent the indent
* @param lineSeparator the lineSeparator
* @throws IOException in case the xml could not be written
*/
public void writeXML(OutputStream outputStream, String encoding, String indent, String lineSeparator)
throws IOException {
XMLOutputter outputter = new XMLOutputter();
Format format = Format.getPrettyFormat();
format.setEncoding(encoding);
format.setIndent(indent);
format.setLineSeparator(lineSeparator);
outputter.setFormat(format);
outputter.output(getDocument(), outputStream);
}
示例14: writeToStream
import org.jdom.output.Format; //導入方法依賴的package包/類
private static void writeToStream(@NotNull OutputStream outputStream, @NotNull Element element) throws IOException {
OutputStreamWriter writer = new OutputStreamWriter(outputStream);
Format format = Format.getPrettyFormat();
format.setLineSeparator("\n");
new XMLOutputter(format).output(element, writer);
}