// Setzen und Lesen von Optionen
// wjh 2000

import java.util.*;
import java.io.*;

class Option1
{
static String configDatei = ".Option1.cfg";
static Properties p = new Properties ();
static FileInputStream in;
static FileOutputStream out;
static boolean fileFound = true;

public static void main (String [] args)
{
if (args.length < 3 )
	{
	System.out.println("Aufruf: Option1 Schluessel = Wert.");  // kein Ü wg. DOS
	System.exit(1);
	}

try 
  {
  in = new FileInputStream(configDatei);
  }
catch (FileNotFoundException e)
  {
  fileFound = false;
  }

if (fileFound)
{

try 
  {
  p.load(in);
  }
catch  (IOException e)
  {
  System.out.println("Optionen nicht ladbar!");
  System.exit(1);
  }
}
// Setze eine Option
p.setProperty(args[0],args[2]);

// Speichere die Optionen
try 
  {
  out = new FileOutputStream(configDatei);
  }
catch (FileNotFoundException e)
  {
  System.out.println("Kann Options-Ausgabe nicht oeffnen.");
  System.exit(2);
  }

try
  {
  p.store(out, "Optionen für das Programm -Option1-");
  }
catch  (IOException e)
  {
  System.out.println("Kann Optionen nicht schreiben!");
  System.exit(1);
  }

System.exit(0);
}
}

