mardi 14 juin 2016

How to iterate through preferences in another class

I have a swing user interface with several textboxes in which the user specifies folder pathnames. These pathnames are then stored in preferences using the Preferences API. I want to allow my application to iterate through the files in the folders by retrieving from the Preferences.This is done from a different class I am unclear as to how I can get the foldernames back out of the preferences and iterate through them.

Here is my code:

 TBB_SQLBuilder settings = new TBB_SQLBuilder();
         for (String n:settings.folderList()){<<<<<WHat do I put instead of this so I can iterate through the Preferences?
            for (String line : Files.readAllLines(Paths.get(n))){
                myFiles.add(line);
            }       
    }

and this is the method from the class TBB_SQLBuilder

public ArrayList<String> folderList() throws IOException{

        String PathForBRAVO = null;
        String PathForImpedance= null;
        String PathForHRM= null;
        String PathForDiagnosis= null;
        String PathForBreath= null;

        prefs = Preferences.userRoot().node(this.getClass().getName());

        if(txtPathForBRAVO!=null){
            prefs.put(PathForBRAVO, txtPathForBRAVO.getText());
        }
        if(txtPathForImpedance!=null){
            prefs.put(PathForImpedance, txtPathForBRAVO.getText());
        }
        if(txtPathForHRM!=null){
            prefs.put(PathForHRM, txtPathForBRAVO.getText());
        }
        if(txtPathForDiagnosis!=null){
            prefs.put(PathForDiagnosis, txtPathForBRAVO.getText());
        }
        if(txtPathForBreath!=null){
            prefs.put(PathForBreath, txtPathForBRAVO.getText());
        }           
        return AL_folderList;       
    }

Aucun commentaire:

Enregistrer un commentaire