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

preintegration testing:javax.prefs.exportNode()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.4.0
    • core-libs
    • None
    • beta
    • x86
    • windows_nt
    • Verified


       Created userRoot.
       Created N1 Node with preferences as key k1 and value v1
       In N1 Node created N2 Node with preferences as key k2 and value v2.
       And exported the N1 node in user01.pfs file.
       When read back the file user01.pfs, only N1 and N2 nodes are exported without
       there keys and values.
      programs:
      import javax.prefs.*;
      import java.io.*;

      public class ExportNodeWrite {
        
          public static void main(String[] args) {
              try{
                 Preferences userRoot = Preferences.userRoot();
                 Preferences N1 = userRoot.node("N1");
                 N1.put("k1","v1");
                 Preferences N2 = N1.node("N2");
                 N2.put("k2","v2");
                 userRoot.flush();
                 
                 File systemFile = new File("user01.pfs");
                 FileOutputStream fos = new FileOutputStream(systemFile);
                 N2.exportNode(fos);
                 fos.close();
                 System.out.println("user01.pfs output");
                 System.out.println();
                 RandomAccessFile raf = new RandomAccessFile("user01.pfs","r");
                 String line = null;
                 while ( (line = raf.readLine()) !=null) {
                    System.out.println(line);
                 }
               } catch(Exception e) {
                  System.out.println("exception thrown " + e);
               }
               
          
         }
       
      }


            jjb Josh Bloch (Inactive)
            spandeorcl Shantaram Pande (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: