Dang, Netscape, here it is again!


Marco Lawrenz wrote:

  I'm converting an application from 3.5.1 to 4.0 using tops.exe. Now
the
  occurences of
  ImmutableHashtable are now converted to NSDictionary.

  Unfortunately the constructor ImmutableHashtable(File aFile) has been
  vanished (after
  it NEVER appeared in 3.5.1- documentation) and wether NSDictionary
  (neither NSMutableDictionary)
  offers a constructor with such parameter.

  Does anybody have an idea how to convert this constructor resp.
  workaround it ?


I did something like this, most of it was in one of the examples
that came with WO 4.0.  You could probably do it someway easier
than this if you looked into it.

    public static NSDictionary getDictionaryFromFile (String
filenameWithPath) {
        try {
            filenameWithPath.replace('\\', '/');  // Fighting NT
            File file = new File(filenameWithPath);
            return (NSDictionary)objectFromPListFile(file);
        } catch (Exception e) {
            System.err.println("Cannot load dictionary from file" + e);
            return null;  // Return null, let them handle it there.
        } // end try
    } // end getDictionaryFromThisFile

    public static Object objectFromPListFile(File file) throws
IOException {
        return
NSPropertyListSerialization.propertyListFromString(stringFromFile(file));

    }

    public static String stringFromFile(File file) throws IOException {
        if (file==null)
            throw new IOException("null file");
        int size=(int) file.length();
        FileInputStream fis=new FileInputStream(file);
        byte [] data = new byte[size];
        int bytesRead=0;
        while (bytesRead<size)
            bytesRead+=fis.read(data,bytesRead,size-bytesRead);
        fis.close();
        return new String(data);
    }

  BTW, the application I'm converting is the DodgeLiteJava demo
  application that came with WO 3.5.1. There is code used in the demos
  which was neither documented nor is taken it over. Reminds me of the
  "undocumented-Windows 3.1"-times.

  Thanks

  -- marco

  ------------------------------------------------
                Marco Lawrenz
  Condat GmbH              Tel: +49-30-39094-208
  AltMoabit 91 d           Fax: +49-30-39094-300
  10559 Berlin             mailto:[EMAIL PROTECTED]
            http://www.condat.de
  CONDAT auf der CeBIT: Halle 3, Stand C64
  ------------------------------------------------

--------------------------------------------
[EMAIL PROTECTED]

Reply via email to