public boolean loadListOfSets() { try { this.clear(); int event; XMLInputFactory inFactory = XMLInputFactory.newInstance(); inFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE); XMLStreamReader parser; InputStreamReader inReader; URLConnection conn; conn = new URL(Konstanten.ADRESSE_VORLAGE_PROGRAMMGRUPPEN).openConnection(); conn.setRequestProperty("User-Agent", Daten.getUserAgent()); conn.setReadTimeout(TIMEOUT); conn.setConnectTimeout(TIMEOUT); inReader = new InputStreamReader(conn.getInputStream(), MSConst.KODIERUNG_UTF); parser = inFactory.createXMLStreamReader(inReader); while (parser.hasNext()) { event = parser.next(); if (event == XMLStreamConstants.START_ELEMENT) { if (parser.getLocalName().equals(PGR)) { // wieder ein neuer Server, toll String[] p = new String[PGR_MAX_ELEM]; get(parser, PGR, PGR_COLUMN_NAMES, p); if (!p[PGR_URL_NR].equals("")) { this.add(p); } } } } } catch (Exception ex) { Log.fehlerMeldung(398001963, ex); return false; } return true; }
public static ListePset importPsetFile(JFrame parent, String dateiUrl, boolean log) { int timeout = 10_000; // 10 Sekunden try { if (GuiFunktionen.istUrl(dateiUrl)) { URLConnection conn; conn = new URL(dateiUrl).openConnection(); conn.setConnectTimeout(timeout); conn.setReadTimeout(timeout); conn.setRequestProperty("User-Agent", Daten.getUserAgent()); return ListePsetVorlagen.importPset( new InputStreamReader(conn.getInputStream(), MSConst.KODIERUNG_UTF), log); } else { return ListePsetVorlagen.importPset( new InputStreamReader(new FileInputStream(dateiUrl), MSConst.KODIERUNG_UTF), log); } } catch (Exception ex) { if (log) { Log.fehlerMeldung(630048926, ex); } return null; } }