/** * Parses the INI-style configuration data from the given resource, * using the given class to find the resource. */ public IniList parseINI(String path, Class<?> c) throws IOException { return parseINI(openTextResource(path, c)); }
public Configuration(String dataFile, String configFile) throws IOException { this.dataFile = dataFile; this.configFile = configFile; BufferedReader reader = new BufferedReader(new InputStreamReader( new FileInputStream(this.configFile), Constants.ENCODING)); IniParser parser = new IniParser(); parser.setCommentDelimiter(null); ini = parser.parseINI(reader); pruneINI(); }
IniParser parser = new IniParser(); parser.setBackslashContinuesLine(false); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
/** * Parses the INI-style wrapping the given file in a {@link BufferedReader} * * @param file the file on disk from which to read * @return the IniList parsed from the file * @throws IOException if the file cannot be read */ public IniList parseINI(File file) throws IOException { FileInputStream fis = null; InputStreamReader isr = null; BufferedReader br = null; try { fis = new FileInputStream(file); isr = new InputStreamReader(fis, Constants.ENCODING); br = new BufferedReader(isr); return parseINI(br); } finally { if (br != null) { br.close(); } if (isr != null) { isr.close(); } if (fis != null) { fis.close(); } } }
StringBuffer sb = new StringBuffer(); while (true) { int num = readLine(in, sb); if (num == 0) break; // eof String line = sb.toString(); if (isHeader(line, '{')) { chapter = parseHeader(line, '{', '}'); continue; if (isHeader(line, '[')) { attrs = new IniTable(); list.add(attrs); String header = parseHeader(line, '[', ']'); if (chapter != null) header = chapter + ": " + header;
/** * Opens a buffered reader for the given resource. * * @param path the name of the resource to read * @return the BufferedReader corresponding to the named resource * @see #openTextResource(String) */ public static BufferedReader openTextResource(String path) { return openTextResource(path, IniParser.class); }
super.initFile(id); parser.setCommentDelimiter(null);
IniParser parser = new IniParser(); parser.setBackslashContinuesLine(false); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
/** * Parses the INI-style wrapping the given file in a {@link BufferedReader} */ public IniList parseINI(File file) throws IOException { FileInputStream fis = null; InputStreamReader isr = null; BufferedReader br = null; try { fis = new FileInputStream(file); isr = new InputStreamReader(fis, Constants.ENCODING); br = new BufferedReader(isr); return parseINI(br); } finally { if (br != null) { br.close(); } if (isr != null) { isr.close(); } if (fis != null) { fis.close(); } } }
StringBuffer sb = new StringBuffer(); while (true) { int num = readLine(in, sb); if (num == 0) break; // eof String line = sb.toString(); if (isHeader(line, '{')) { chapter = parseHeader(line, '{', '}'); continue; if (isHeader(line, '[')) { attrs = new IniTable(); list.add(attrs); String header = parseHeader(line, '[', ']'); if (chapter != null) header = chapter + ": " + header;
/** Opens a buffered reader for the given resource. */ public static BufferedReader openTextResource(String path) { return openTextResource(path, IniParser.class); }
super.initFile(id); parser.setCommentDelimiter(null);
public void parseConfigFile(String configFile) throws IOException { File file = new File(configFile); if (file.isDirectory()) { return; } String parent = file.getParent(); if (configDir != null) { parent = relocateToRoot(parent); } configFile = file.getAbsolutePath(); String dir = file.getParentFile().getAbsolutePath(); IniParser parser = new IniParser(); parser.setCommentDelimiter(null); FileInputStream stream = new FileInputStream(configFile); IniList iniList = parser.parseINI(new BufferedReader( new InputStreamReader(stream, Constants.ENCODING))); for (IniTable table : iniList) { String id = table.get(IniTable.HEADER_KEY); id = id.substring(0, id.lastIndexOf(" ")); id = new File(parent, id).getAbsolutePath(); DefaultMutableTreeNode node = findNode(id, true, configFile); if (node == null) { LOGGER.warn("config file '{}' has invalid filename '{}'", configFile, id); continue; } } }
/** Parses the INI-style configuration data from the given resource. */ public IniList parseINI(String path) throws IOException { return parseINI(openTextResource(path)); }
private IniList getIniFile(String filename) throws FormatException, IOException { LOGGER.debug("getIniFile procession: {}", filename); RandomAccessInputStream stream = getFile(filename); String data = stream.readString((int) stream.length()); if (!data.startsWith("[")) { data = data.substring(data.indexOf('['), data.length()); } data = DataTools.stripString(data); BufferedReader reader = new BufferedReader(new StringReader(data)); stream.close(); IniList list = parser.parseINI(reader); // most of the values will be wrapped in double quotes for (IniTable table : list) { LOGGER.debug(""); LOGGER.debug("[" + table.get(IniTable.HEADER_KEY) + "]"); String[] keys = table.keySet().toArray(new String[table.size()]); for (String key : keys) { String value = sanitizeValue(table.get(key)); LOGGER.debug(key + " = " + value); table.put(key, value); } } reader.close(); return list; }
data = data.replaceAll("ReadFromDoc", ""); IniParser parser = new IniParser(); parser.setCommentDelimiter(";"); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
/** * Parses the INI-style configuration data from the given resource. * * @param path the name of the resource to read * @return the IniList parsed from the named resource * @see #openTextResource(String) * @throws IOException if the resource cannot be read */ public IniList parseINI(String path) throws IOException { return parseINI(openTextResource(path)); }