當前位置: 首頁>>代碼示例>>Java>>正文


Java Format.setEncoding方法代碼示例

本文整理匯總了Java中org.jdom.output.Format.setEncoding方法的典型用法代碼示例。如果您正苦於以下問題:Java Format.setEncoding方法的具體用法?Java Format.setEncoding怎麽用?Java Format.setEncoding使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jdom.output.Format的用法示例。


在下文中一共展示了Format.setEncoding方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doOutput

import org.jdom.output.Format; //導入方法依賴的package包/類
public void doOutput(List<StudentEntity> students){
	  	Element root = new Element("students");  
        Document document = new Document(root);  
        Iterator<StudentEntity> iter = students.iterator();
        while(iter.hasNext()){
        	StudentEntity student = iter.next();
        	Element studentEl = new Element("student");
        	studentEl.addContent(new Element("studentnumber").setText(student.getStudentNumber()));
        	studentEl.addContent(new Element("studentname").setText(student.getStudentName()));
        	studentEl.addContent(new Element("major").setText(student.getMajor()));
        	studentEl.addContent(new Element("grade").setText(student.getGrade()));
        	studentEl.addContent(new Element("classname").setText(student.getClassName()));
        	studentEl.addContent(new Element("gender").setText(student.getGender()));
        	root.addContent(studentEl);
        }
        try {
	        XMLOutputter out = new XMLOutputter();  
            Format f = Format.getPrettyFormat();  
            f.setEncoding("UTF-8");
            out.setFormat(f);  
            out.output(document, new FileOutputStream(outputFile)); 
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
}
 
開發者ID:ousheobin,項目名稱:My-Javaweb-Homework,代碼行數:26,代碼來源:XMLOutputUtil.java

示例2: writeToXml

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Writes the JDOM document to the outputstream specified
 * @param out	the outputstream to which the JDOM document should be writed
 * @param validate if true, validate the dom structure before writing. If there is a validation error,
 * 		or the xsd is not in the classpath, an exception will be thrown.
 * @throws ConverterException
 */
public void writeToXml(Pathway pwy, OutputStream out, boolean validate) throws ConverterException {
	Document doc = createJdom(pwy);
	
	//Validate the JDOM document
	if (validate) validateDocument(doc);
	//			Get the XML code
	XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
	Format f = xmlcode.getFormat();
	f.setEncoding("UTF-8");
	f.setTextMode(Format.TextMode.PRESERVE);
	xmlcode.setFormat(f);

	try
	{
		//Send XML code to the outputstream
		xmlcode.output(doc, out);
	}
	catch (IOException ie)
	{
		throw new ConverterException(ie);
	}
}
 
開發者ID:PathVisio,項目名稱:pathvisio,代碼行數:30,代碼來源:GpmlFormat2010a.java

示例3: export

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * @param t_objdb
 * @param string
 * @throws IOException 
 * @throws SQLException 
 */
public void export(DBInterface a_objDB, String a_strFileName) throws IOException, SQLException 
{
    this.m_objDB = a_objDB;
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("defaults");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    this.exportResidues(t_objRoot);
    this.exportPersubstitutions(t_objRoot);
    this.exportIons(t_objRoot);
    this.exportDericatisation(t_objRoot);
    this.exportMolecules(t_objRoot);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    FileWriter t_objWriter = new FileWriter(a_strFileName);
    t_objExportXML.output(t_objDocument, t_objWriter );
}
 
開發者ID:glycoinfo,項目名稱:eurocarbdb,代碼行數:32,代碼來源:GeneratorDefault.java

示例4: 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();
}
 
開發者ID:PathVisio,項目名稱:pathvisio,代碼行數:15,代碼來源:DgpmlOutputter.java

示例5: export

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * @param t_objdb
 * @param string
 * @throws IOException 
 * @throws SQLException 
 */
public void export(DBInterface a_objDB, String a_strFileName) throws IOException, SQLException 
{
    this.m_objDB = a_objDB;
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("fragments");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    this.exportAX(t_objRoot);
    this.exportOthers(t_objRoot);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    FileWriter t_objWriter = new FileWriter(a_strFileName);
    t_objExportXML.output(t_objDocument, t_objWriter );
}
 
開發者ID:glycoinfo,項目名稱:eurocarbdb,代碼行數:29,代碼來源:GeneratorFragment.java

示例6: exportParameter

import org.jdom.output.Format; //導入方法依賴的package包/類
/** 
 * Exports a parameter object to an XML string
 * 
 * @param t_objSetting
 * @return XML-string
 * @throws IOException
 */
public String exportParameter(CalculationParameter t_objSetting) throws IOException
{
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("glycopeakfinder_calculation");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    t_objRoot.setAttribute(new Attribute("noNamespaceSchemaLocation",this.m_strFile, xsiNS));
    // write Settings to element
    this.exportParameter(t_objRoot, t_objSetting);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    StringWriter t_objWriter = new StringWriter();
    t_objExportXML.output(t_objDocument, t_objWriter );
    return t_objWriter.toString();
}
 
開發者ID:glycoinfo,項目名稱:eurocarbdb,代碼行數:31,代碼來源:CalcParameterXml.java

示例7: writeToFile

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Save a xml document in a file
 * @param fname the name of the file to be created
 * @param doc the xml document
 */
public static void writeToFile(String fname, Document doc){
	try{
		FileOutputStream out = new FileOutputStream(fname);
		
		Format format = Format.getPrettyFormat();
		format.setIndent("	");
		format.setEncoding("ISO-8859-1");
		XMLOutputter op = new XMLOutputter(format);
		op.output(doc,out);
		out.flush();
		out.close();
	}
	catch (IOException e){
		System.err.println(e);
	}
}
 
開發者ID:tvaquero,項目名稱:itsimple,代碼行數:22,代碼來源:XMLUtilities.java

示例8: 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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:16,代碼來源:JPFClasspathFixProcessor.java

示例9: 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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:NewPluginWizard.java

示例10: 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;
}
 
開發者ID:Ekryd,項目名稱:sortpom,代碼行數:9,代碼來源:XmlOutputGenerator.java

示例11: output

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Writes to an Writer the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure the Writer instance is using the same charset encoding.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @param writer Writer to write the XML representation for the given WireFeed.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws IOException thrown if there was some problem writing to the Writer.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public void output(WireFeed feed,Writer writer,boolean prettyPrint) throws IllegalArgumentException,IOException, FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    outputter.output(doc,writer);
}
 
開發者ID:4thline,項目名稱:feeds,代碼行數:28,代碼來源:WireFeedOutput.java

示例12: 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);
}
 
開發者ID:netceteragroup,項目名稱:trema-core,代碼行數:20,代碼來源:XMLDatabase.java

示例13: outputString

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Creates a String with the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure that if the String is written to a character stream the stream charset is the same as
 * the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @return a String with the XML representation for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public String outputString(WireFeed feed) throws IllegalArgumentException,FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = Format.getPrettyFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(doc);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:WireFeedOutput.java

示例14: output

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Writes to an Writer the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure the Writer instance is using the same charset encoding.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @param writer Writer to write the XML representation for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws IOException thrown if there was some problem writing to the Writer.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public void output(WireFeed feed,Writer writer) throws IllegalArgumentException,IOException, FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = Format.getPrettyFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    outputter.output(doc,writer);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:WireFeedOutput.java

示例15: outputString

import org.jdom.output.Format; //導入方法依賴的package包/類
/**
 * Creates a String with the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure that if the String is written to a character stream the stream charset is the same as
 * the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @return a String with the XML representation for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public String outputString(WireFeed feed, boolean prettyPrint) throws IllegalArgumentException,FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(doc);
}
 
開發者ID:4thline,項目名稱:feeds,代碼行數:28,代碼來源:WireFeedOutput.java


注:本文中的org.jdom.output.Format.setEncoding方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。