FileDocCategorySizeDatePackage
FlipProperty.javaAPI DocExample874Wed Jun 25 17:10:44 BST 2003com.develop.ss.ant

FlipProperty.java

package com.develop.ss.ant;

import java.util.Properties;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileOutputStream;

public class FlipProperty {
  public static void main(String[] args) throws IOException {
    flip(args[0], args[1]);
  }

  private static void flip(String propFile, String propName) throws IOException {
    Properties props = new Properties();
    FileInputStream inStream = new FileInputStream(propFile);
    props.load(inStream);
    inStream.close();
    String value = props.getProperty(propName);
    int newValue = 1 - Integer.parseInt(value);
    props.setProperty(propName, Integer.toString(newValue));
    FileOutputStream out = new FileOutputStream(propFile);
    props.store(out, "Auto saved by " + FlipProperty.class);
    out.close();
  }

}