Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4061282

Properties class does not 'force' String objects

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 1.1.1, 1.2.0
    • core-libs
    • x86
    • windows_95



      Name: sgC58550 Date: 06/25/97


      This is in the context of an application
      Take an instance of java.utils.Properties class, insert an
      Object other than java.lang.String. After this has been
      accomplihed attempt to use
      java.utils.Properties.save(OutputStream,String) a
      ClassCastError is given with out much reason. The output only
      has the header and property name followed by an =.

      public static void main(String args[]) {
         try {
            Properties myProps = new Properties();
            myProps.put("One",new Integer(1));
            FileOutputStream os = new FileOutputStream("outprops");
            myProps.save(os,"My Props");
            os.flush();
            os.close();
         }catch(Exception ex) {
            ex.printStackTrace();
            Sytem.exit(1);
         }
         System.exit(0);
      }

      company - , email - ###@###.###
      ======================================================================

            mmcclosksunw Michael Mccloskey (Inactive)
            sgoodsunw Sheri Good (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: