code: public static MavenSettings load(InputStream input) throws Exception {
  		XMLStreamReader xml = XMLInputFactory.newFactory().createXMLStreamReader(input);
  		while (xml.hasNext()) {
  			xml.next();
  			if (xml.getEventType() == XMLStreamConstants.START_ELEMENT) {
  				if (!"settings".equals(xml.getLocalName()))
  					throw new Exception("Root element of a Maven settings.xml file must be <settings>");
  				MavenSettings settings = new MavenSettings();
  				while (xml.hasNext()) {
  					xml.next();
  					if (xml.getEventType() == XMLStreamConstants.START_ELEMENT) {
  						if ("localRepository".equals(xml.getLocalName())) {
  							settings.localRepository = xml.getElementText().trim();
  						} else if ("activeProfiles".equals(xml.getLocalName())) {
  							while (xml.hasNext()) {
  								xml.next();
  								if (xml.getEventType() == XMLStreamConstants.START_ELEMENT) {
  									if ("activeProfile".equals(xml.getLocalName()))
  										settings.activeProfiles.add(xml.getElementText().trim());
  								} else if (xml.getEventType() == XMLStreamConstants.END_ELEMENT)
  									break;
  							}
  						}
  					} else if (xml.getEventType() == XMLStreamConstants.END_ELEMENT)
  						break;
  				}
  				settings.activeProfiles.trimToSize();
  				return settings;
  			}
  		}
  		return new MavenSettings();
  	}
docs: Load a settings file.