Package org.ini4j

Examples of org.ini4j.Wini


  public ConfigReader(InputStream fileInputStream) throws IOException {
    this(fileInputStream, null);
  }
 
  public ConfigReader(InputStream fileInputStream, File workingDirectory) throws IOException {
    ini = new Wini(fileInputStream) {
      private static final long serialVersionUID = 1L;

      @Override
      public String get(Object sectionName, Object optionName) {
        if (sectionName.equals("project")) {
View Full Code Here


   *
   * @throws IOException If an exception occours.
   */
  public synchronized void storeSettings() throws IOException {

    Wini settingsFile = new Wini();

    settingsFile.add( GRAPHICS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.ANTIALIAS.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.ANTIALIAS ) );
    settingsFile.add( GRAPHICS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.OPENGL.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.OPENGL ) );
    settingsFile.add( GRAPHICS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.REDRAW_FPS.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.REDRAW_FPS ) );

    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.KEY_LEFT.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.KEY_LEFT ) );
    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.KEY_RIGHT.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.KEY_RIGHT ) );
    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.KEY_UP.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.KEY_UP ) );
    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.KEY_DOWN.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.KEY_DOWN ) );
    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.KEY_PAUSE.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.KEY_PAUSE ) );
    settingsFile.add( CONTROLS_SETTINGS_SECTION,
                      INTEGER_SETTINGS_TYPE.MOVE_MILLIS_TIMEOUT.toString(),
                      "" + this.getNextRunValue( INTEGER_SETTINGS_TYPE.MOVE_MILLIS_TIMEOUT ) );

    settingsFile.add( RESOURCES_SETTINGS_SECTION,
                      STRING_SETTINGS_TYPE.LEVELS_PATH.toString(),
                      this. getNextRunValue( STRING_SETTINGS_TYPE.LEVELS_PATH ) );
    settingsFile.add( RESOURCES_SETTINGS_SECTION,
                      STRING_SETTINGS_TYPE.TEXTURES_PATH.toString(),
                      this.getNextRunValue( STRING_SETTINGS_TYPE.TEXTURES_PATH ) );

    File preferencesDirectory = getRelativeDirectory( "." );
    settingsFile.store( new File( preferencesDirectory, DEFAULT_CONFIG_FILE ) );
  }
View Full Code Here

  }

  @NotNull
  private Preferences loadPreferences() throws IOException {
    File preferencesDirectory = getRelativeDirectory( "." );
    Wini ini = new Wini( new File( preferencesDirectory, DEFAULT_CONFIG_FILE ) );
    return new IniPreferences( ini );
  }
View Full Code Here

    private static String serverRconPassword;
    private static boolean readIni;

    @BeforeClass
    public static void readServerParameters() {
        Wini serverSettings;

        URL url = RconPacketTest.class.getResource("/server-settings.ini");

        try {
            serverSettings = new Wini(new File(url.getFile()));
        } catch (Exception e) {
            //if we reach this point then the file server-settings.ini doesn't exist or
            //an error occurred.
            serverIp = null;
            serverPort = 0;
            serverRconPassword = null;
            readIni = false;
            return;
        }

        serverIp = serverSettings.get("server-settings", "serverIp");
        serverPort = serverSettings.get("server-settings", "serverPort", int.class);
        serverRconPassword = serverSettings.get("server-settings", "serverRconPassword");
        readIni = true;

    }
View Full Code Here

TOP

Related Classes of org.ini4j.Wini

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.