private void generatePublicXml(ResPackage pkg, Directory out, XmlSerializer serial) throws AndrolibException { try { OutputStream outStream = out.getFileOutput("values/public.xml"); serial.setOutput(outStream, null); serial.startDocument(null, null); serial.startTag(null, "resources"); for (ResResSpec spec : pkg.listResSpecs()) { serial.startTag(null, "public"); serial.attribute(null, "type", spec.getType().getName()); serial.attribute(null, "name", spec.getName()); serial.attribute(null, "id", String.format("0x%08x", spec.getId().id)); serial.endTag(null, "public"); } serial.endTag(null, "resources"); serial.endDocument(); serial.flush(); outStream.close(); } catch (IOException | DirectoryException ex) { throw new AndrolibException("Could not generate public.xml file", ex); } }
serializer.endTag("", "gpx"); serializer.endDocument(); serializer.flush(); } catch (IOException e) { e.printStackTrace();
serializer.flush();
xmlSerializer.flush(); return scratchOutputStream.toByteArray();
public void flush() throws IOException { xs.flush(); }
public void flush() throws IOException { xs.flush(); }
/** * Ends a XML document. */ public static void endXmlDocument(XmlSerializer writer) throws IOException { assert writer != null; // end document writer.endDocument(); writer.flush(); writer.toString(); }
@SuppressLint("SetWorldReadable") private void endXml() { try { mXmlSerializer.endTag(null, "screenshots"); mXmlSerializer.endDocument(); mXmlSerializer.flush(); } catch (IOException e) { throw new RuntimeException(e); } try { mOutputStream.close(); } catch (IOException e) { throw new RuntimeException(e); } }
void endTestSuites() { try { if (mTestSuiteSerializer != null) { mTestSuiteSerializer.endTag(null, "testsuites"); mTestSuiteSerializer.endDocument(); mTestSuiteSerializer.flush(); } if (mWriter != null) { mWriter.flush(); mWriter.close(); } } catch (IOException e) { throw new RuntimeException(e); } } }
void endTestSuites() { try { if (mTestSuiteSerializer != null) { mTestSuiteSerializer.endTag(null, "testsuites"); mTestSuiteSerializer.endDocument(); mTestSuiteSerializer.flush(); } if (mWriter != null) { mWriter.flush(); mWriter.close(); } } catch (IOException e) { throw new RuntimeException(e); } } }
public void convertRSSToHtml(XmlPullParser parser, XmlSerializer writer) throws IOException, XmlPullParserException { // <!ELEMENT rss (channel)> if (parser.nextTag() == XmlPullParser.START_TAG && parser.getName().equals("rss")) { writer.startTag(null,"html"); if (parser.nextTag() == XmlPullParser.START_TAG && parser.getName().equals("channel")) { convertChannelToHtml(parser, writer); parser.require(XmlPullParser.END_TAG, null, "channel"); } else { new RuntimeException("expectd channel start tag not "+parser.getPositionDescription()); } parser.nextTag(); parser.require(XmlPullParser.END_TAG, null, "rss"); writer.endTag(null, "html"); writer.flush(); } else { throw new RuntimeException("expectd an RSS document at" + parser.getPositionDescription()); } }
/** * Method description * * * @param element * * @return */ protected String marshallObject(Object element) { if (element instanceof String) { return (String) element; } else if (element instanceof BaseSchemaEntity) { try { StringWriter writer = new StringWriter(); XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer(); serializer.setOutput(writer); ((BaseSchemaEntity) element).toXml(serializer); serializer.flush(); return writer.toString(); } catch (Exception e) { throw new LinkedInApiClientException("Unkown element encountered:" + element, e); } } else { throw new LinkedInApiClientException("Unkown element encountered:" + element); } }
private static CharSequence writeSvg(Context ctx, Vector vector) { if (vector != null) { try { CharArrayWriter writer = new CharArrayWriter(); XmlSerializer serializer = Xml.newSerializer(); serializer.setOutput(writer); serializer.startTag(SVG_NAMESPACE, "svg"); serializer.attribute(SVG_NAMESPACE, "width", String.format(Locale.US, "%f", vector.mWidth)); serializer.attribute(SVG_NAMESPACE, "height", String.format(Locale.US, "%f", vector.mHeight)); serializer.attribute(SVG_NAMESPACE, "viewBox", String.format(Locale.US, "0 0 %f %f", vector.mWidth, vector.mHeight)); for (Group group : vector.mGroups) { serializeGroup(ctx, serializer, vector, group); } for (Path path : vector.mPaths) { serializePath(ctx, serializer, path); } serializer.endTag(SVG_NAMESPACE, "svg"); serializer.endDocument(); serializer.flush(); return writer.toString(); } catch (Exception ex) { Log.e(TAG, "Can't write svg xml", ex); } } return null; }
@Override public final void write(OutputStream out) throws IOException { try { xml = XmlPullParserFactory.newInstance().newSerializer(); } catch(XmlPullParserException e) { throw new RuntimeException("Cannot initialize serializer", e); } xml.setOutput(out, CHARSET); xml.startDocument(CHARSET, null); write(); if(xml.getName() != null) { throw new IllegalStateException("Forgot to close a tag"); } xml.endDocument(); xml.flush(); }
/** * Saves an Animation to disk as an XML file. * @param file the full path to the destination file * @param a the Animation to save * @throws XmlPullParserException * @throws IOException * @throws IllegalArgumentException * @throws FileNotFoundException */ static void saveAnimation( String file, Animation a, ChannelsParameterSource source, Set<SynchronizedPointGroup> syncPointGroups) throws XmlPullParserException, IOException, IllegalArgumentException, FileNotFoundException{ XmlSerializer xs = XMLUtils.getXmlFileSerializer(file); xs.startDocument(null, null); xs.text("\n"); //new line after xml version tag. writeAnimation(xs, a, file, source, syncPointGroups); xs.endDocument(); xs.flush(); }
/** * Serialize item to given writer. * * @param item an Object * @param writer a Writer * * @exception XmlBuilderException * */ public void serializeToWriter(Object item, //XmlContainer node, Writer writer) //throws XmlPullParserException, IOException, IllegalArgumentException throws XmlBuilderException { XmlSerializer ser = null; try { ser = factory.newSerializer(); ser.setOutput(writer); } catch (Exception e) { throw new XmlBuilderException("could not serialize node to writer", e); } serialize(item, ser); try { ser.flush(); } catch (IOException e) { throw new XmlBuilderException("could not flush output", e); } }
/** * Serialize item to given writer. * * @param item an Object * @param writer a Writer * * @exception XmlBuilderException * */ public void serializeToWriter(Object item, //XmlContainer node, Writer writer) //throws XmlPullParserException, IOException, IllegalArgumentException throws XmlBuilderException { XmlSerializer ser = null; try { ser = factory.newSerializer(); ser.setOutput(writer); } catch (Exception e) { throw new XmlBuilderException("could not serialize node to writer", e); } serialize(item, ser); try { ser.flush(); } catch (IOException e) { throw new XmlBuilderException("could not flush output", e); } }
ser.flush(); } catch (IOException e) { throw new XmlBuilderException("could not flush output", e);
ser.flush(); } catch (IOException e) { throw new XmlBuilderException("could not flush output", e);
static boolean parseToXml(ApplicationList applications, OutputStream out) { XmlSerializer serializer = Xml.newSerializer(); try { serializer.setOutput(out, "UTF-8"); serializer.startTag(ns, "fdroid"); for (ApplicationDetails app : applications) { serializer.startTag(ns, "application"); writeTag(serializer, ID, app.getPackageName()); writeTag(serializer, LAST_UPDATED, app.getLastUpdatedDateString()); writeTag(serializer, NAME, app.getProjectName()); writeTag(serializer, DESCRIPTION, app.getDescription()); writeTag(serializer, ICON_URL, app.getIconUrl()); writeTag(serializer, SOURCE_URL, app.getSourceCodeUrl()); writeTag(serializer, WEB, app.getProjectWebUrl()); writeTag(serializer, MAIL, app.getProjectMail()); serializer.endTag(ns, "application"); } serializer.endTag(ns, "fdroid"); serializer.flush(); return true; } catch (IOException e) { e.printStackTrace(); return false; } }