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

java.util.Properties.save() method outputs corrupted Unicode data

XMLWordPrintable

    • 1.1fcs
    • generic
    • generic
    • Not verified

       
      masayoshi.okutsu@Eng 1997-01-06
      The save method of java.util.Properties outputs corrupted Unicode
      data. The following program reproduces the problem. Note that the test
      result includes Japanese text (EUC).

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

      public class testPro{
      public static void main(String args[]){
      String[][] contents = {
               {"s1", "3"},
      {"s2", "MeinDisk"},
      {"s3", "\u6f22\u5b57"},
      {"s4", "3 Mar 96"},
      };

      Properties props = new Properties();
      for (int i = 0; i < contents.length; ++i) {
      props.put(contents[i][0],contents[i][1]);
      }

      try{
      FileOutputStream file = new FileOutputStream("JavaTest");
      props.save(file, "Properties");
      file.close();
      }
      catch(IOException a){
      a.printStackTrace();
      }
      }
      }

      The result in the output file, JavaTest:

      #Properties
      #”™ ¢¢ã¾ 12 04:48:21 GMT+00:00 1996
      s4=3 Mar 96
      s3=\u^F^O^B^B\u^E^K^E^G
      s2=MeinDisk
      s1=3

            pbk Peter Kessler
            okutsu Masayoshi Okutsu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: