Here you can find the source of isXMLFile(File file)
Parameter | Description |
---|---|
file | aa |
Parameter | Description |
---|---|
ParserConfigurationException | aa |
public static boolean isXMLFile(File file) throws ParserConfigurationException
//package com.java2s; /* DigiDoc4J library// w ww. j a va 2s .c om * * This software is released under either the GNU Library General Public * License (see LICENSE.LGPL). * * Note that the only valid version of the LGPL license as far as this * project is concerned is the original GNU Library General Public License * Version 2.1, February 1999 */ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.*; public class Main { /** * @param file aa * @return aa * @throws ParserConfigurationException aa */ public static boolean isXMLFile(File file) throws ParserConfigurationException { DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); try { builder.parse(file); } catch (Exception e) { return false; } return true; } }