/** Parses the INI-style configuration data from the given resource. */ public IniList parseINI(String path) throws IOException { return parseINI(openTextResource(path)); }
/** * 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)); }
/** * 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)); }
/** * Parses the INI-style configuration data from the given resource, * using the given class to find the resource. * * @param path the name of the resource to read * @param c the Class to use for finding the named resource * @return the IniList parsed from the named resource * @see #openTextResource(String, Class) * @throws IOException if the resource cannot be read */ public IniList parseINI(String path, Class<?> c) throws IOException { return parseINI(openTextResource(path, c)); }
public OptionsList(String path, Class<?> c) throws IOException { this(new IniParser().parseINI(path, c)); }
public OptionsList(String path, Class<?> c) throws IOException { this(new IniParser().parseINI(path, c)); }
/** * 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(); } } }
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(); }
/** * 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(); } } }
private void parseHeader() throws IOException { String headerData = in.findString("{END}"); dataOffset = in.getFilePointer(); IniParser parser = new IniParser(); ini = parser.parseINI(new BufferedReader(new StringReader(headerData))); }
private void parseHeader() throws IOException { String headerData = in.findString("{END}"); dataOffset = in.getFilePointer(); IniParser parser = new IniParser(); ini = parser.parseINI(new BufferedReader(new StringReader(headerData))); }
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; } } }
private void parseChannelData(Location dir) throws IOException { emWave = new double[channelNames.size()]; exWave = new double[channelNames.size()]; exposure = new double[channelNames.size()]; gain = new double[channelNames.size()]; offset = new double[channelNames.size()]; for (int c=0; c<channelNames.size(); c++) { Location dyeFile = new Location(dir, channelNames.get(c) + ".dye"); IniList dye = null; try (RandomAccessInputStream stream = new RandomAccessInputStream(dyeFile.getAbsolutePath()); InputStreamReader isr = new InputStreamReader(stream, Constants.ENCODING); BufferedReader br = new BufferedReader(isr)) { dye = new IniParser().parseINI(br); } IniTable numerator = dye.getTable("Numerator"); String em = numerator.get("Emission"); em = em.substring(0, em.indexOf(' ')); emWave[c] = Double.parseDouble(em); String ex = numerator.get("Excitation"); ex = ex.substring(0, ex.lastIndexOf(" ")); if (ex.indexOf(' ') != -1) { ex = ex.substring(ex.lastIndexOf(" ") + 1); } exWave[c] = Double.parseDouble(ex); exposure[c] = Double.parseDouble(numerator.get("Exposure")); gain[c] = Double.parseDouble(numerator.get("Gain")); offset[c] = Double.parseDouble(numerator.get("Offset")); } }
private void parseChannelData(Location dir) throws IOException { emWave = new double[channelNames.size()]; exWave = new double[channelNames.size()]; exposure = new double[channelNames.size()]; gain = new double[channelNames.size()]; offset = new double[channelNames.size()]; for (int c=0; c<channelNames.size(); c++) { Location dyeFile = new Location(dir, channelNames.get(c) + ".dye"); IniList dye = null; try (RandomAccessInputStream stream = new RandomAccessInputStream(dyeFile.getAbsolutePath()); InputStreamReader isr = new InputStreamReader(stream, Constants.ENCODING); BufferedReader br = new BufferedReader(isr)) { dye = new IniParser().parseINI(br); } IniTable numerator = dye.getTable("Numerator"); String em = numerator.get("Emission"); em = em.substring(0, em.indexOf(' ')); emWave[c] = Double.parseDouble(em); String ex = numerator.get("Excitation"); ex = ex.substring(0, ex.lastIndexOf(" ")); if (ex.indexOf(' ') != -1) { ex = ex.substring(ex.lastIndexOf(" ") + 1); } exWave[c] = Double.parseDouble(ex); exposure[c] = Double.parseDouble(numerator.get("Exposure")); gain[c] = Double.parseDouble(numerator.get("Gain")); offset[c] = Double.parseDouble(numerator.get("Offset")); } }
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; }
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; }
parser.setCommentDelimiter(";"); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
parser.setCommentDelimiter(";"); IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));
IniList ini = parser.parseINI(new BufferedReader(new StringReader(data)));