public static boolean languageDetected(String eadfile, String language, String langCode)
            throws XMLStreamException, FactoryConfigurationError, IOException {



        FileInputStream fileInputStreamEAD = new FileInputStream(eadfile);
        XMLEventFactory eventFactory = XMLEventFactory.newInstance();
        XMLEventReader xmlEventReaderEAD = XMLInputFactory.newInstance()
                .createXMLEventReader(fileInputStreamEAD);

        XMLEvent end = eventFactory.createDTD("\n");

        String value = "";

        boolean inLangUsage=false;
        boolean languageAlreadyAvailable = false;
        boolean langusageFound = false;

        while (xmlEventReaderEAD.hasNext()) {
            XMLEvent event = xmlEventReaderEAD.nextEvent();

            /**
             * <profiledesc> 
             *   <langusage> 
             *     <language langcode="dut">Nederlands</language> 
             *   </langusage> 
             * </profiledesc>
             */
            if (event.isStartElement()) {
                if (event.asStartElement().getName().getLocalPart().equals("langusage")){
                    inLangUsage = true;
                } 
                if (event.asStartElement().getName().getLocalPart()
                        .equals("language") && inLangUsage) {
                    Iterator<Attribute> attributes = event.asStartElement().getAttributes();
                    while (attributes.hasNext()) {
                        Attribute attribute = attributes.next();
                        if (attribute.getName().toString().equals("langcode")) {
                            languageAlreadyAvailable=true;
                        }
                    }

                }
            }



        }
        return languageAlreadyAvailable;

    }