private void loadTextProperties(Properties props, String text) { Properties loaded = new Properties(); try { Parser.loadProperties(loaded, true, new ByteArrayInputStream(text.getBytes("UTF-8"))); } catch (UnsupportedEncodingException e) { throw new PaxmlRuntimeException(e); } loaded = Parser.trimProperties(loaded); props.putAll(loaded); }
/** * Load properties from a resource file and more text if given. * * @param props * the properties file to load into * @param res * a resource to load from, null to ignore * @param moreText * a text to load from, null to ignore * @return the input properties */ public static Properties loadProperties(Properties props, Resource res, String moreText) { InputStream[] ins = new InputStream[2]; if (res != null) { try { ins[0] = res.getInputStream(); } catch (IOException e) { throw new PaxmlRuntimeException("Cannot load properties from resource " + res, e); } } if (moreText != null) { try { ins[1] = new ByteArrayInputStream(moreText.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new PaxmlRuntimeException(e); } } return loadProperties(props, true, ins); }
Parser.loadProperties(props, res, null);