congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
XmlUtils.getUtfReader
Code IndexAdd Tabnine to your IDE (free)

How to use
getUtfReader
method
in
com.android.utils.XmlUtils

Best Java code snippets using com.android.utils.XmlUtils.getUtfReader (Showing top 2 results out of 315)

origin: com.amazon.device.tools.build/builder

  private static String getStringValue(@NonNull File file, @NonNull String xPath) {
    XPath xpath = AndroidXPathFactory.newXPath();

    try {
      InputSource source = new InputSource(XmlUtils.getUtfReader(file));
      return xpath.evaluate(xPath, source);
    } catch (XPathExpressionException e) {
      // won't happen.
    } catch (IOException e) {
      throw new RuntimeException(e);
    }

    return null;
  }
}
origin: com.android.tools/common

/**
 * Parses the given UTF file as a DOM document, using the JDK parser. The parser does not
 * validate, and is optionally namespace aware.
 *
 * @param file           the UTF encoded file to parse
 * @param namespaceAware whether the parser is namespace aware
 * @return the DOM document
 */
@NonNull
public static Document parseUtfXmlFile(@NonNull File file, boolean namespaceAware)
    throws ParserConfigurationException, IOException, SAXException {
  DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  Reader reader = getUtfReader(file);
  try {
    InputSource is = new InputSource(reader);
    factory.setNamespaceAware(namespaceAware);
    factory.setValidating(false);
    DocumentBuilder builder = factory.newDocumentBuilder();
    return builder.parse(is);
  } finally {
    reader.close();
  }
}
com.android.utilsXmlUtilsgetUtfReader

Javadoc

Returns a character reader for the given file, which must be a UTF encoded file.

The reader does not need to be closed by the caller (because the file is read in full in one shot and the resulting array is then wrapped in a byte array input stream, which does not need to be closed.)

Popular methods of XmlUtils

  • parseDocument
    Parses the given XML string as a DOM document, using the JDK parser. The parser does not validate, a
  • parseDocumentSilently
    Parses the given XML string as a DOM document, using the JDK parser. The parser does not validate, a
  • parseUtfXmlFile
    Parses the given UTF file as a DOM document, using the JDK parser. The parser does not validate, and
  • toXmlAttributeValue
    Converts the given attribute value to an XML-attribute-safe value, meaning that single and double qu
  • toXml
  • toXmlTextValue
    Converts the given attribute value to an XML-text-safe value, meaning that less than and ampersand c
  • fromXmlAttributeValue
    Converts the given XML-attribute-safe value to a java string
  • getRootTagName
    Returns the name of the root element tag stored in the given file, or null if it can't be determined
  • lookupNamespacePrefix
    Returns the namespace prefix matching the requested namespace URI. If no such declaration is found,
  • append
    Dump node to string without indentation adjustments
  • appendXmlAttributeValue
    Appends text to the given StringBuilder and escapes it as required for a DOM attribute node.
  • appendXmlTextValue
    Appends text to the given StringBuilder and escapes it as required for a DOM text node.
  • appendXmlAttributeValue,
  • appendXmlTextValue,
  • getSourceFilePosition,
  • stripBom

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • getContentResolver (Context)
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Path (java.nio.file)
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Table (org.hibernate.mapping)
    A relational table
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now