🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #15113

Re: Reading INI files.

#15113
From: Pascal Warnimont
Date: Fri, 09 Jul 1999 00:00
73 lines
1986 bytes
Hoops just realised I forgot to paste the code I was talking about :
package utilities;

import java.util.Properties;
import java.io.*;

public class IniFile
{
  private Properties properties;
  private String fileName;

  public IniFile(String  newFileName)
  {
      if (newFileName== null)
        throw new NullPointerException();
      else
        fileName = newFileName;
  }

  // Write the properties to the file.
  public static void writeProperties(Properties  p, String fileName) throws
IOException
  {
      FileOutputStream out = new FileOutputStream(fileName);
      p.save(out,"");
      out.close();
  }

  public static Properties readProperties(String fileName) throws
IOException
  {
      Properties  p = new Properties();
      FileInputStream in = new FileInputStream(fileName);
      p.load(in);
      in.close();
      return p;
  }

  public static void main(String[]  arg)
  {
      test();
  }


  public static void test()
  {
    Properties p = new Properties();

    p.put("LocalOrganisationId", "IDG");
    p.put("Printer", "Test");
    p.put("Debug", "1");
    p.put("Trace", "Meuh");

    Properties r;

      try
      {
          writeProperties(p, "test.ini");
          p.list(System.out);

          r = readProperties("test.ini");
          r.list(System.out);
      }
      catch(IOException ioe)
      {
        ioe.printStackTrace();
      }

  }

  }

}
Technical Details
Message-ID: <7m4p5n$jrh5@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7lga7t$17e3@forums.borland.com> <7m2gmg$hqs2@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,c248fdff5160d5e3
X-Google-Attributes: gidf74b3,public
From: "Pascal Warnimont" <pwa@endless-interactive.com>
Subject: Re: Reading INI files.
Date: 1999/07/09
Message-ID: <7m4p5n$jrh5@forums.borland.com>
X-Deja-AN: 499071089
References: <7lga7t$17e3@forums.borland.com> <7m2gmg$hqs2@forums.borland.com>
Organization: Endless-interactive
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
Newsgroups: borland.public.jbuilder.java.language