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);
}
}
}
- duplicates
-
JDK-4397109 java.util.prefs.Preferences exportNode(java.io.OutputStream os)
-
- Closed
-
-
JDK-4397371 java.util.prefs.Preferences exportSubtree() storing from userRoot key and value
-
- Closed
-