Parse the specified file into a DOM Document.

@param file
The file to parse.
@return The parsed DOM Document or null if an error occurs.
505838
private Document loadValidating(File file) {
		try {
			return getDOMObject(file.getAbsolutePath(), true);
		} catch (SAXException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		} catch (IOException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
			System.out.println("Error parsing digital document from nitf file "
					+ file + ".");
		}
		return null;
	}
900619
public static <T extends Parameters> T parse(File file, T parameters) throws AponParseException {
        return parse(file, null, parameters);
    }
569611
public void loadTagMappingFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (!f.exists()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a file that does not exist");
            }
            if (f.isDirectory()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a directory, must be a file");
            } else if (!f.canRead()) {
                throw new IllegalArgumentException(
                        "tag mapping file parameter points to a file we have no read permissions");
            }

            try {
                this.tagMapping = f.toURI().toURL();
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        } else {
            this.tagMapping = PoiWriterTask.class.getClassLoader().getResource("poi-mapping.xml");
        }
    }
481836
public Document parse(File file) throws SAXException, IOException
    {
        return verify(_WrappedBuilder.parse(file));
    }
1146963
private Document parse(final String data) {
    if (docBuilder == null || data == null) {
      return null;
    }
    Document document = null;

    try {
      // we change the system ID to a valid URI so that Crimson won't
      // complain. Indeed, "log4j.dtd" alone is not a valid URI which
      // causes Crimson to barf. The Log4jEntityResolver only cares
      // about the "log4j.dtd" ending.

      /**
       * resetting the length of the StringBuffer is dangerous, particularly
       * on some JDK 1.4 impls, there's a known Bug that causes a memory leak
       */
      StringBuffer buf = new StringBuffer(1024);

      buf.append(BEGINPART);
      buf.append(data);
      buf.append(ENDPART);

      InputSource inputSource =
        new InputSource(new StringReader(buf.toString()));
      document = docBuilder.parse(inputSource);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return document;
  }
1207236
public static String readContent( File file ) throws IOException
    {
        Reader input = null;
        try
        {
            input = new FileReader( file );
            return readContent( input );
        }
        finally
        {
            closeQuietly( input );
        }
    }
779327
public void parseFile(File file, boolean utterancePerDoc) {
        try {
            // Build an xml document.
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(file);

            // Extract all utterances.
            NodeList utterances = doc.getElementsByTagName("u");
            StringBuilder fileBuilder = new StringBuilder();
            for (int i = 0; i < utterances.getLength(); ++i) {
                // Extract all words from the utterance
                Element item = (Element) utterances.item(i);
                NodeList words = item.getElementsByTagName("w");
                StringBuilder utteranceBuilder = new StringBuilder();

                // Iterate over the words and get just the word text.
                List<String> wordsInUtterance =
                    new ArrayList<String>(words.getLength());
                for (int j = 0; j < words.getLength(); ++j) {
                    // Get the part of speech tag.
                    Element wordNode = (Element) words.item(j);
                    NodeList posNodeList = wordNode.getElementsByTagName("pos");
                    String word = wordNode.getFirstChild().getNodeValue();
                    if (posNodeList.getLength() > 0) {
                        Node posNode = 
                            posNodeList.item(0).getFirstChild().getFirstChild();
                        String pos = posNode.getNodeValue();
                        posTags.put(word, pos);
                        if (appendPosTags)
                            word += "-" + pos;
                    }
                    wordsInUtterance.add(word);
                }

                // Each of the <a> nodes contains additional information about
                // the currnet utterances.  This may be syntactic information,
                // comments on the scene, descriptions of the action, or
                // clarification by the observer.  For all comments but the
                // syntactic, use the comment text to create new pseudo
                // utterances by combining tokens from the utterance with
                // pseudo-tokens in the comment.  The pseudo-tokens have a
                // "-GROUNDING" suffix which distiguishes them from tokens
                // actually present in the uttered speech.
                NodeList auxNodes = item.getElementsByTagName("a");
                List<String> augmentedUtterances = new LinkedList<String>();
                if (generateAugmented) {
                    for (int j = 0; j < auxNodes.getLength(); ++j) {
                        // Get any comment for the utterance
                        Node n = auxNodes.item(j);
                        String auxNodeType = n.getAttributes().
                            getNamedItem("type").getNodeValue();

                        // Get only those nodes that contain comments or
                        // descriptions on the utterance that may be used to
                        // ground the words being referred to.
                        if (auxNodeType.equals("action")
                            || auxNodeType.equals("actions")
                            || auxNodeType.equals("addressee")
                            || auxNodeType.equals("comments")
                            || auxNodeType.equals("explanation")
                            || auxNodeType.equals("gesture")
                            || auxNodeType.equals("happening")
                            || auxNodeType.equals("situation")) {
                            
                            String commentOnUtterance = 
                                n.getFirstChild().getNodeValue();
                            // Use the iterator factory to tokenize in the event
                            // that the user has specified some form of token
                            // filtering
                            Iterator<String> tokenIter = 
                                IteratorFactory.tokenize(
                                        new BufferedReader(
                                            new StringReader(
                                                commentOnUtterance)));
                            // For each of the tokens in the additional
                            // information, create a pseudo-utterance using a
                            // word from the actual utterance and an
                            // grounding-token
                            while (tokenIter.hasNext()) {
                                String token = tokenIter.next();
                                for (String word : wordsInUtterance) {
                                    augmentedUtterances.add(word + " "
                                        + token + "-GROUNDING");
                                }
                            }
                        }
                    }
                }
                    
                // Write the utterance if an utterance is a document.
                for (Iterator<String> it = wordsInUtterance.iterator(); 
                         it.hasNext(); ) {
                    utteranceBuilder.append(it.next());
                    if (it.hasNext())
                        utteranceBuilder.append(" ");
                }
                String utterance = utteranceBuilder.toString();
                if (utterancePerDoc) {
                    print(utterance);
                    // Print all the psuedo utterances constructed from the
                    // comments
                    for (String aug : augmentedUtterances)
                        print(aug);
                }
                else {  // otherwise save the utterance.
                    fileBuilder.append(utterance);
                    if (separateByPeriod)
                        fileBuilder.append(".");
                    fileBuilder.append(" ");

                    // Print all the psuedo utterances constructed from the
                    // comments.  Unlike the utterances, print these as separate
                    // documents to avoid having them register as co-occurrences
                    // with other utterances.
                    for (String aug : augmentedUtterances)
                        print(aug);
                }
            }

            // Write all the utterances if the whole xml file is a document.
            if (!utterancePerDoc)
                print(fileBuilder.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
89296
public static ConfigDocument parseFile(File file, ConfigParseOptions options) {
        return Parseable.newFile(file, options).parseConfigDocument();
    }
877928
public T loadXml(File file) {

    FileResource resource = new FileResource(file);
    return loadXml(resource);
  }
1094010
public static void parse(DocListener document, String file) {
        HtmlParser p = new HtmlParser();
        p.go(document, file);
    }
121224
public Result<String> convertToHtml(File file) throws IOException {
        return new InternalDocumentConverter(options).convertToHtml(file).toResult();
    }
152402
public static function loadFromFile(string $file): Dom
    {
        $dom       = new Dom;
        self::$dom = $dom;

        return $dom->loadFromFile($file);
    }
544269
function parse(file) {
  var rules = {};

  file
    .split(/\n/m)
    .filter(function (line) {
      return (/^\/\//).test(line) ? null : line;
    })
    .map(function (line) {
      return process(line.split("."), rules);
    });

  return rules;
}
301984
public static Document toDocument(File file) throws SAXException, IOException {
		InputStream in = new BufferedInputStream(new FileInputStream(file));
		try {
			return XmlUtils.toDocument(in);
		} finally {
			in.close();
		}
	}
564806
public void loadTagMappingFile(String file) {
        if (file != null) {
            File f = new File(file);
            if (!f.exists()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a file that does not exist");
            }
            if (f.isDirectory()) {
                throw new IllegalArgumentException("tag mapping file parameter points to a directory, must be a file");
            } else if (!f.canRead()) {
                throw new IllegalArgumentException(
                        "tag mapping file parameter points to a file we have no read permissions");
            }

            try {
                this.tagMapping = OSMTagMapping.getInstance(f.toURI().toURL());
            } catch (MalformedURLException e) {
                throw new RuntimeException(e);
            }
        } else {
            this.tagMapping = OSMTagMapping.getInstance();
        }
        this.tagMapping.setTagValues(this.tagValues);
    }
1159859
public Map<String, Map<String, List<BigDecimal>>> parse(final String file) {
		try (BufferedReader reader = new BufferedReader(new InputStreamReader(openResource(file), StandardCharsets.UTF_8))) {
			Map<String, Map<String, List<BigDecimal>>> benchmarks = new TreeMap<>(Collections.reverseOrder());

			for (String line = reader.readLine(); line != null; line = reader.readLine()) {
				Matcher matcher = LINE_PATTERN.matcher(line);
				if (matcher.matches()) {
					String framework = matcher.group(GROUP_FRAMEWORK_NAME);
					String benchmark = matcher.group(GROUP_BENCHMARK_NAME);
					String score = matcher.group(GROUP_SCORE_VALUE);

					if (!frameworks.contains(framework)) {
						Logger.error("Unknown logging framework: \"{}\"", framework);
						return Collections.emptyMap();
					}

					BigDecimal parsedScore = new BigDecimal(score.replaceAll("[,\\.]", "."));

					Map<String, List<BigDecimal>> benchmarkEntry = benchmarks.get(benchmark);
					if (benchmarkEntry == null) {
						benchmarkEntry = new LinkedHashMap<>();
						benchmarks.put(benchmark, benchmarkEntry);
					}

					List<BigDecimal> scores = benchmarkEntry.get(framework);
					if (scores == null) {
						scores = new ArrayList<>();
						benchmarkEntry.put(framework, scores);
					}

					scores.add(parsedScore);
				}
			}

			return benchmarks;
		} catch (IOException ex) {
			Logger.error(ex, "Failed to open \"{}\"", file);
			return Collections.emptyMap();
		}
	}
64896
public void parseFile(File file) throws ParserException, IOException {

        Reader reader = null;

        try {
            reader = new FileReader(file);
            nanoElement.parseFromReader(reader);
        } catch (XMLParseException e) {
            throw new ParserException(e.getMessage());
        } finally {
            if (reader != null) reader.close();
        }
    }