Here you can find the source of putList(String path, ArrayList
Parameter | Description |
---|---|
path | The absolute path name of the node. |
list | The list of strings. |
public static void putList(String path, ArrayList<String> list)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.prefs.Preferences; public class Main { /** Put a list of strings to preferences. The list is stored as a size property end element_N properties with N being the element index.//ww w. j a v a 2 s . c o m @param path The absolute path name of the node. @param list The list of strings. */ public static void putList(String path, ArrayList<String> list) { Preferences prefs = createNode(path); if (prefs == null) return; prefs.putInt("size", list.size()); for (int i = 0; i < list.size(); ++i) prefs.put("element_" + i, list.get(i)); } /** Get node path, create if not already existing. @param path The absolute path name of the node. @return The node */ public static Preferences createNode(String path) { assert !path.startsWith("/"); return Preferences.userRoot().node(path); } }