本文整理匯總了Java中org.ini4j.Ini.load方法的典型用法代碼示例。如果您正苦於以下問題:Java Ini.load方法的具體用法?Java Ini.load怎麽用?Java Ini.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.ini4j.Ini
的用法示例。
在下文中一共展示了Ini.load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPicUrl
import org.ini4j.Ini; //導入方法依賴的package包/類
private String getPicUrl(String filename)
{
String url = null;
Ini ini = new Ini();
String filepath = configData.coolqDir + "/data/image/" + filename + ".cqimg";
try
{
ini.load(new FileReader(filepath));
} catch (IOException e)
{
e.printStackTrace();
}
Ini.Section section = ini.get("image");
url = section.get("url");
return url;
}
示例2: test
import org.ini4j.Ini; //導入方法依賴的package包/類
private void test(String filename, String defaultEncoding) throws Exception
{
Charset charset = (defaultEncoding == null) ? Config.DEFAULT_FILE_ENCODING : Charset.forName(defaultEncoding);
UnicodeInputStreamReader reader = new UnicodeInputStreamReader(getClass().getResourceAsStream(filename), charset);
Ini ini = new Ini();
ini.setConfig(Config.getGlobal().clone());
ini.getConfig().setFileEncoding(charset);
ini.load(reader);
Ini.Section sec = ini.get("section");
if (sec == null)
{
throw new IllegalStateException("Missing section: section");
}
if (!"value".equals(sec.get("option")))
{
throw new IllegalStateException("Missing option: option");
}
}
示例3: WifImporter
import org.ini4j.Ini; //導入方法依賴的package包/類
public WifImporter(BitmessageContext ctx, InputStream in, Pubkey.Feature... features) throws IOException {
this.ctx = ctx;
Ini ini = new Ini();
ini.load(in);
for (Entry<String, Profile.Section> entry : ini.entrySet()) {
if (!entry.getKey().startsWith("BM-"))
continue;
Profile.Section section = entry.getValue();
BitmessageAddress address = Factory.createIdentityFromPrivateKey(
entry.getKey(),
getSecret(section.get("privsigningkey")),
getSecret(section.get("privencryptionkey")),
Long.parseLong(section.get("noncetrialsperbyte")),
Long.parseLong(section.get("payloadlengthextrabytes")),
Pubkey.Feature.bitfield(features)
);
if (section.containsKey("chan")) {
address.setChan(Boolean.parseBoolean(section.get("chan")));
}
address.setAlias(section.get("label"));
identities.add(address);
}
}
示例4: MyConfig
import org.ini4j.Ini; //導入方法依賴的package包/類
MyConfig() throws IOException {
System.out.println("Parsing config.ini");
org.ini4j.Config.getGlobal().setEscape(false);
Ini ini = new Ini();
ini.load(new FileReader("config.ini"));
Ini.Section section = ini.get("paths");
//TODO check if these are valid directories
this._inputRoot = this.getIniValue(section, "input dir") + File.separator;
this._outputRoot = this.getIniValue(section, "output dir") + File.separator;
this._imPath = this.getIniValue(section, "imagemagick dir") + File.separator;
section = ini.get("surface map");
this.minZoomSurface = Integer.parseInt(this.getIniValue(section, "min zoom"));
this.maxZoomSurface = Integer.parseInt(this.getIniValue(section, "max zoom"));
this.defZoomSurface = Integer.parseInt(this.getIniValue(section, "default zoom"));
section = ini.get("underground map");
this.minZoomUnderground = Integer.parseInt(this.getIniValue(section, "min zoom"));
this.maxZoomUnderground = Integer.parseInt(this.getIniValue(section, "max zoom"));
this.defZoomUnderground = Integer.parseInt(this.getIniValue(section, "default zoom"));
ini.clear();
}
示例5: read
import org.ini4j.Ini; //導入方法依賴的package包/類
/**
* Creates an instance of GitConfig by reading information from the specified {@code .git/config} file.
* @throws RepoStateException if {@code .git/config} couldn't be read or has invalid format.<br/>
* If in general it has valid format, but some sections are invalid, it skips invalid sections, but reports an error.
*/
@NotNull
static GitConfig read(@NotNull GitPlatformFacade platformFacade, @NotNull File configFile) {
Ini ini = new Ini();
ini.getConfig().setMultiOption(true); // duplicate keys (e.g. url in [remote])
ini.getConfig().setTree(false); // don't need tree structure: it corrupts url in section name (e.g. [url "http://github.com/"]
try {
ini.load(configFile);
}
catch (IOException e) {
LOG.error(new RepoStateException("Couldn't load .git/config file at " + configFile.getPath(), e));
return new GitConfig(Collections.<Remote>emptyList(), Collections.<Url>emptyList(), Collections.<BranchConfig>emptyList());
}
IdeaPluginDescriptor plugin = platformFacade.getPluginByClassName(GitConfig.class.getName());
ClassLoader classLoader = plugin == null ? null : plugin.getPluginClassLoader(); // null if IDEA is started from IDEA
Pair<Collection<Remote>, Collection<Url>> remotesAndUrls = parseRemotes(ini, classLoader);
Collection<BranchConfig> trackedInfos = parseTrackedInfos(ini, classLoader);
return new GitConfig(remotesAndUrls.getFirst(), remotesAndUrls.getSecond(), trackedInfos);
}
示例6: build
import org.ini4j.Ini; //導入方法依賴的package包/類
private static void build(String name)
throws FileNotFoundException, IOException, SerializationException, TranscriptParseException {
// create temporary directory
File tmpDir = Files.createTempDir();
// copy files
ResourceUtils.copyResourceToFile("/ex_" + name + "/transcript.gff3", new File(tmpDir + "/transcript.gff3"));
ResourceUtils.copyResourceToFile("/ex_" + name + "/hgnc_complete_set.txt", new File(tmpDir + "/hgnc_complete_set.txt"));
ResourceUtils.copyResourceToFile("/ex_" + name + "/ref.fa", new File(tmpDir + "/ref.fa"));
ResourceUtils.copyResourceToFile("/ex_" + name + "/rna.fa", new File(tmpDir + "/rna.fa"));
ResourceUtils.copyResourceToFile("/ex_" + name + "/data.ini", new File(tmpDir + "/data.ini"));
// build ReferenceDictionary
ReferenceDictionaryBuilder refDictBuilder = new ReferenceDictionaryBuilder();
refDictBuilder.putContigID("ref", 1);
refDictBuilder.putContigLength(1, 500001);
refDictBuilder.putContigName(1, "ref");
ReferenceDictionary refDict = refDictBuilder.build();
// parse TranscriptModel
Ini ini = new Ini();
ini.load(new File(tmpDir + "/data.ini"));
RefSeqParser parser = new RefSeqParser(refDict, tmpDir.toString(), ini.get("dummy"));
ImmutableList<TranscriptModel> tms = parser.run();
JannovarData data = new JannovarData(refDict, tms);
// write out file
new JannovarDataSerializer("mini_" + name + ".ser").save(data);
}
示例7: getSection
import org.ini4j.Ini; //導入方法依賴的package包/類
private Section getSection(File serversFile) throws FileNotFoundException, IOException {
FileInputStream is = new FileInputStream(serversFile);
Ini ini = new Ini();
try {
ini.load(is);
} finally {
is.close();
}
return ini.get("global");
}
示例8: loadConfig
import org.ini4j.Ini; //導入方法依賴的package包/類
private static void loadConfig() throws IOException {
determineConfigDir();
File configFile = new File(configDir + "/server.ini");
if(!configFile.exists() || !configFile.isFile()) {
Util.copyResourceTo("default.ini", configFile);
}
Ini conf = new Ini();
conf.load(configFile);
configuration = new NectarServerConfiguration(conf);
}
示例9: loadIni
import org.ini4j.Ini; //導入方法依賴的package包/類
public static IniEntity loadIni(String fileName) throws IOException {
Config cfg = new Config();
URL url = ConfigLoader.class.getClassLoader().getResource(fileName);
cfg.setMultiSection(true);
Ini ini = new Ini();
ini.setConfig(cfg);
ini.load(url);
return new IniEntity(ini);
}
示例10: sample04
import org.ini4j.Ini; //導入方法依賴的package包/類
void sample04(URL location) throws IOException
{
Config cfg = new Config();
cfg.setMultiOption(true);
Ini ini = new Ini();
ini.setConfig(cfg);
ini.load(location);
Ini.Section sec = ini.get("sneezy");
Dwarf sneezy = sec.as(Dwarf.class);
int[] numbers = sneezy.getFortuneNumber();
//
// same as above but with unmarshalling...
//
DwarfBean sneezyBean = new DwarfBean();
sec.to(sneezyBean);
numbers = sneezyBean.getFortuneNumber();
//}
assertArrayEquals(DwarfsData.sneezy.fortuneNumber, numbers);
assertEquals(DwarfsData.sneezy.fortuneNumber.length, sec.length("fortuneNumber"));
assertArrayEquals(DwarfsData.sneezy.fortuneNumber, sneezy.getFortuneNumber());
assertArrayEquals(DwarfsData.sneezy.fortuneNumber, sneezyBean.getFortuneNumber());
}
示例11: loadDwarfsIni
import org.ini4j.Ini; //導入方法依賴的package包/類
public static Ini loadDwarfsIni(Config config) throws Exception
{
Ini ini = new Ini();
ini.setConfig(config);
ini.load(Helper.class.getClassLoader().getResourceAsStream(DWARFS_INI));
return ini;
}
示例12: loadTaleIni
import org.ini4j.Ini; //導入方法依賴的package包/類
public static Ini loadTaleIni(Config config) throws Exception
{
Ini ini = new Ini();
ini.setConfig(config);
ini.load(Helper.class.getClassLoader().getResourceAsStream(TALE_INI));
return ini;
}
示例13: parse
import org.ini4j.Ini; //導入方法依賴的package包/類
private boolean parse() {
Ini ini = new Ini();
try {
ini.load(file);
Section smtp = ini.get("smtp");
smtpPort = Integer.parseInt(smtp.get("port"));
host = smtp.get("host");
Section imap = ini.get("imap");
imapPort = Integer.parseInt(imap.get("port"));
Section db = ini.get("database");
salt = db.get("salt");
maxMailSize = Long.parseLong(db.get("max_mail_size"));
Section keys = ini.get("keys");
keystore = keys.get("keystore");
keyPassword = keys.get("password");
forceSSL = Boolean.parseBoolean(keys.get("forcessl"));
Section debug = ini.get("debug");
if (debug != null) {
this.debug = Boolean.parseBoolean(debug.get("messages"));
}
return true;
} catch (Exception e) {
JustLogger.logger().severe("Error while reading config: " + e.getLocalizedMessage());
}
return false;
}
示例14: read
import org.ini4j.Ini; //導入方法依賴的package包/類
/**
* Creates an instance of GitConfig by reading information from the specified {@code .git/config} file.
* <p/>
* If some section is invalid, it is skipped, and a warning is reported.
*/
@NotNull
static GitConfig read(@NotNull GitPlatformFacade platformFacade, @NotNull File configFile) {
GitConfig emptyConfig = new GitConfig(Collections.<Remote>emptyList(), Collections.<Url>emptyList(),
Collections.<BranchConfig>emptyList());
if (!configFile.exists()) {
LOG.info("No .git/config file at " + configFile.getPath());
return emptyConfig;
}
Ini ini = new Ini();
ini.getConfig().setMultiOption(true); // duplicate keys (e.g. url in [remote])
ini.getConfig().setTree(false); // don't need tree structure: it corrupts url in section name (e.g. [url "http://github.com/"]
try {
ini.load(configFile);
}
catch (IOException e) {
LOG.warn("Couldn't load .git/config file at " + configFile.getPath(), e);
return emptyConfig;
}
IdeaPluginDescriptor plugin = platformFacade.getPluginByClassName(GitConfig.class.getName());
ClassLoader classLoader = plugin == null ?
GitConfig.class.getClassLoader() : // null e.g. if IDEA is started from IDEA
plugin.getPluginClassLoader();
Pair<Collection<Remote>, Collection<Url>> remotesAndUrls = parseRemotes(ini, classLoader);
Collection<BranchConfig> trackedInfos = parseTrackedInfos(ini, classLoader);
return new GitConfig(remotesAndUrls.getFirst(), remotesAndUrls.getSecond(), trackedInfos);
}
示例15: load
import org.ini4j.Ini; //導入方法依賴的package包/類
@Override
protected void load(Path path, byte[] data) throws Exception {
Map<String, Map<Integer, String>> outMap = new HashMap<>();
Ini ini = new Ini();
ini.load(new ByteArrayInputStream(data));
for(final Section section : ini.values()) {
outMap.put(section.getName(), parseInibinKeys(ini.get(section.getName())));
}
m_InibinViewer.setKeyMappings(outMap);
}