本文整理汇总了Java中org.ini4j.Wini类的典型用法代码示例。如果您正苦于以下问题:Java Wini类的具体用法?Java Wini怎么用?Java Wini使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Wini类属于org.ini4j包,在下文中一共展示了Wini类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AbstractContext
import org.ini4j.Wini; //导入依赖的package包/类
public AbstractContext() {
// Exists only to defeat instantiation
try {
StringBuilder sb = new StringBuilder();
sb.append(System.getProperty("user.home"));
sb.append(File.separator);
sb.append(".river-framework");
sb.append(File.separator);
sb.append(getConfigurationFileName());
String location = sb.toString();
Wini context = new Wini(new File(location));
testDatabaseServer = context.get("default", "test-database-server");
testDatabasePath = context.get("default", "test-database-path");
remoteDatabaseServer = context.get("default", "remote-database-server");
remoteDatabasePath = context.get("default", "remote-database-path");
} catch (Exception e) {
throw new RiverException(e);
}
}
示例2: sample01
import org.ini4j.Wini; //导入依赖的package包/类
void sample01(String filename) throws IOException
{
Wini ini = new Wini(new File(filename));
int age = ini.get("happy", "age", int.class);
double height = ini.get("happy", "height", double.class);
String dir = ini.get("happy", "homeDir");
//}
//| ... assuming there is a section with name <<<happy>>>, which contains at least
//| the following options: <<<age>>>, <<<height>>> and <<<homeDir>>>, something like
//| this:
//|
//|+---------+
//| [happy]
//| age = 99
//| height = 77.66
//| homeDir = /home/happy
//|+---------+
//|
//|
assertEquals(DwarfsData.happy.age, age);
assertEquals(DwarfsData.happy.height, height, Helper.DELTA);
assertEquals(DwarfsData.happy.homeDir, dir);
}
示例3: sample02
import org.ini4j.Wini; //导入依赖的package包/类
void sample02(String filename) throws IOException
{
Wini ini = new Wini(new File(filename));
ini.put("sleepy", "age", 55);
ini.put("sleepy", "weight", 45.6);
ini.store();
//}
//| ... and then file will have a section <<<sleepy>>> and this section
//| will contains at least two options: <<<age>>> with value <<<55>>> and <<<weight>>>
//| with value <<<45.6>>>, something like this:
//|
//|+---------+
//| [sleepy]
//| age = 55
//| weight = 45.6
//|+---------+
//|
assertEquals(55, (int) ini.get(Dwarfs.PROP_SLEEPY, Dwarf.PROP_AGE, int.class));
assertEquals(45.6, ini.get(Dwarfs.PROP_SLEEPY, Dwarf.PROP_WEIGHT, double.class), Helper.DELTA);
}
示例4: save
import org.ini4j.Wini; //导入依赖的package包/类
public void save() throws IOException {
if (this.inifile == null || this.inifile.isEmpty()) {
return;
}
File f = new File(this.inifile);
if (!f.exists()) {
f.getParentFile().mkdirs();
f.createNewFile();
}
Wini ini = new Wini(f);
ini.put("server", "host", this.bindHost);
ini.put("server", "port", this.bindPort);
ini.put("server", "thread", this.threadNum);
ini.put("redis", "host", this.redisHost);
ini.put("redis", "port", this.redisPort);
ini.put("redis", "db", this.redisDb);
ini.put("watch", "interval", this.interval);
ini.store();
}
示例5: generatePatchDesc
import org.ini4j.Wini; //导入依赖的package包/类
public static String generatePatchDesc(ME3TweaksPatchPackage pack) {
Wini ini = new Wini();
// put modmanager, PATCHINFO
ini.put("ModManager", "cmmver", pack.getTargetversion());
ini.put("PatchInfo", "patchname", pack.getPatchname());
ini.put("PatchInfo", "patchdesc", pack.getPatchdesc());
ini.put("PatchInfo", "patchdev", pack.getPatchdev());
ini.put("PatchInfo", "patchver", pack.getPatchver());
ini.put("PatchInfo", "targetmodule", pack.getTargetmodule());
ini.put("PatchInfo", "targetfile", pack.getTargetfile());
ini.put("PatchInfo", "targetsize", pack.getTargetsize());
ini.put("PatchInfo", "finalizer", pack.isFinalizer());
ini.put("PatchInfo", "me3tweaksid", pack.getMe3tweaksid());
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
ini.store(os);
return new String(os.toByteArray(), "ASCII");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "";
}
示例6: Mod
import org.ini4j.Wini; //导入依赖的package包/类
/**
* Loads a moddesc from a stream of bytes. Typically this is from a
* compressed archive.
*
* @param bytes
*/
public Mod(ByteArrayInOutStream bytes) {
modDescFile = new File(System.getProperty("user.dir"));
ignoreLoadErrors = true;
modifyString = "";
jobs = new ArrayList<ModJob>();
try {
Wini wini = new Wini();
wini.load(bytes.getInputStream());
readDesc(wini);
} catch (Exception e) {
ModManager.debugLogger.writeErrorWithException("Error reading moddesc.ini from stream:", e);
setValidMod(false);
return;
}
}
示例7: unserialize
import org.ini4j.Wini; //导入依赖的package包/类
@Override
public void unserialize(Wini ini) {
String fontFamily = ini.get(INI_SECTION_TICKER, INI_VALUE_FONT_FAMILY);
if (fontFamily != null && fontFamily.length() > 0) {
this.fontFamily = fontFamily;
}
int fontSize = ini.get(INI_SECTION_TICKER, INI_VALUE_FONT_SIZE, int.class);
if (fontSize > 0) {
this.fontSize = fontSize;
}
String backgroundColor = ini.get(INI_SECTION_TICKER, INI_VALUE_BACKGROUND_COLOR);
if (backgroundColor != null && backgroundColor.length() > 0) {
this.backgroundColor = Color.web(backgroundColor);
}
String textColor = ini.get(INI_SECTION_TICKER, INI_VALUE_TEXT_COLOR);
if (textColor != null && textColor.length() > 0) {
this.textColor = Color.web(textColor);
}
}
示例8: create
import org.ini4j.Wini; //导入依赖的package包/类
/**
* Creates a car counter instance.
*
* @param ini the configuration file.
* @return the car counter.
*/
public CarCounter create(Wini ini)
{
String implementation = ini.get("Counting", "implementation", String.class);
if ("opencv".equals(implementation))
{
return new OpencvCarCounter();
}
else if ("noop".equals(implementation))
{
return new NoopCarCounter();
}
else
{
throw new IllegalStateException("Unknown counting backend: " + implementation);
}
}
示例9: DefaultProcessor
import org.ini4j.Wini; //导入依赖的package包/类
public DefaultProcessor(Wini ini)
{
dateTimeExtractor = new MotionDateTimeExtractor();// TODO: via config
carCounter = new CarCounterFactory().create(ini);
storage = new StorageFactory().create(ini);
String incoming = ini.get("Processing", "incoming", String.class);
Preconditions.checkState(StringUtils.isNotBlank(incoming), "An incoming directory is required");
incomingDirectory = Paths.get(incoming);
if (!Files.isDirectory(incomingDirectory))
{
throw new IllegalStateException("Incoming path is not an existing directory: " + incoming);
}
String data = ini.get("Processing", "data", String.class);
Preconditions.checkState(StringUtils.isNotBlank(data), "An data directory is required");
dataDirectory = Paths.get(data);
if (!Files.isDirectory(dataDirectory))
{
throw new IllegalStateException("Data path is not an existing directory: " + data);
}
logger.info(String.format("Starting processor: incoming:[%s] data:[%s]", incoming, data));
}
示例10: setUp
import org.ini4j.Wini; //导入依赖的package包/类
@Before
public void setUp() throws Exception
{
dbFile = Files.createTempFile("test", ".db");
String iniValue = String.format(
"[Storage]\n" +
"implementation = sqlite\n" +
"database = %s\n",
dbFile);
try (InputStream stream = IOUtils.toInputStream(iniValue, StandardCharsets.UTF_8))
{
ini = new Wini(stream);
}
}
示例11: IniParser
import org.ini4j.Wini; //导入依赖的package包/类
/**
* Loads an ini file
* @param iniFile
* @throws FileNotFoundException
*/
public IniParser( String iniFile ) throws FileNotFoundException {
if ( iniFile == null ) {
iniFile = "config";
}
if ( new File( iniFile ).isDirectory() || !new File( iniFile ).exists() ) {
throw new FileNotFoundException( "INI-Configfile not found: " + iniFile );
}
try {
ini = new Wini( new File( iniFile ) );
} catch ( IOException e ) {
e.printStackTrace();
throw new FileNotFoundException( "INI-Configfile not found: " + iniFile );
}
}
示例12: sample02
import org.ini4j.Wini; //导入依赖的package包/类
void sample02(String filename) throws IOException
{
Wini ini = new Wini(new File(filename));
ini.put("sleepy", "age", 55);
ini.put("sleepy", "weight", 45.6);
ini.store();
//}
//| ... and then file will have a section <<<sleepy>>> and this section
//| will contains at least two options: <<<age>>> with value <<<55>>> and <<<weight>>>
//| with value <<<45.6>>>, something like this:
//|
//|+---------+
//| [sleepy]
//| age = 55
//| weight = 45.6
//|+---------+
//|
assertEquals(55, (int) ini.get(Dwarfs.PROP_SLEEPY, Dwarf.PROP_AGE, int.class));
assertEquals(45.6, (double) ini.get(Dwarfs.PROP_SLEEPY, Dwarf.PROP_WEIGHT, double.class), Helper.DELTA);
}
示例13: ROMData
import org.ini4j.Wini; //导入依赖的package包/类
public ROMData(String header) throws IOException {
this(
new Wini(
ROMData.class.getClassLoader().getResourceAsStream("roms.ini")
),
header
);
}
示例14: getUrl
import org.ini4j.Wini; //导入依赖的package包/类
public static String getUrl(String tipo, String servico) throws CteException {
try {
ConfiguracoesIniciais config = ConfiguracoesIniciais.getInstance();
String secao = tipo + "_" + config.getEstado() + "_"
+ (config.getAmbiente().equals(ConstantesCte.AMBIENTE.HOMOLOGACAO) ? "H" : "P");
InputStream is = WebServiceUtil.class.getResourceAsStream("/WebServicesCte.ini");
Wini ini = new Wini(is);
String url = ini.get(secao, "Usar");
if (url == null) {
url = secao;
}
if (!config.getEstado().equals(Estados.MG)
|| !config.getEstado().equals(Estados.MS)
|| !config.getEstado().equals(Estados.MT)
|| !config.getEstado().equals(Estados.RS)
|| !config.getEstado().equals(Estados.SP)
|| !config.getEstado().equals(Estados.PR)) {
secao = url;
}
if (servico.equals(ConstantesCte.SERVICOS.DISTRIBUICAO_DFE)) {
url = ini.get("CTe_AN_"+(config.getAmbiente().equals(ConstantesCte.AMBIENTE.HOMOLOGACAO) ? "H" : "P"), servico);
} else {
url = ini.get(secao, servico + "_" + config.getVersao());
}
System.out.println("Versão Cte: " + config.getVersao() + " - WebService: " + url);
return url;
} catch (IOException e) {
throw new CteException(e.getMessage());
}
}
示例15: getUrlConsultaCadastro
import org.ini4j.Wini; //导入依赖的package包/类
public static String getUrlConsultaCadastro(String uf) throws NfeException {
String tipo = ConstantesUtil.NFE;
String servico = ConstantesUtil.SERVICOS.CONSULTA_CADASTRO;
try {
ConfiguracoesIniciaisNfe config = ConfiguracoesIniciaisNfe.getInstance();
String secao = tipo + "_" + uf.toUpperCase() + "_"
+ (config.getAmbiente().equals(ConstantesUtil.AMBIENTE.HOMOLOGACAO) ? "H" : "P");
InputStream is = WebServiceUtil.class.getResourceAsStream("/WebServices.ini");
Wini ini = new Wini(is);
String url = ini.get(secao, "Usar");
url = ini.get(secao, servico);
if(ObjetoUtil.isEmpty(url)){
throw new NfeException("WebService de "+servico+" não encontrado para "+uf);
}
System.out.println("WebService - " + url);
return url;
} catch (IOException e) {
throw new NfeException(e.getMessage());
}
}